Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Turn this text-based program into a gui #Creates item class for all menu items class item: def __init__(self,food,ws,retail,sold): self.food = food self.ws = ws self.retail

Turn this text-based program into a gui

#Creates item class for all menu items class item: def __init__(self,food,ws,retail,sold): self.food = food self.ws = ws self.retail = retail self.sold = sold def __str__(self): return f"{self.food} {self.ws} {self.retail} {self.sold}" #Restaurant manager menu function def print_menu(menu): index = 1 print("\t(Wholesale, Retail, Amt. Sold)") for i in menu: print(f"{index}. {i.food:<15} ${i.ws} ${i.retail} #{i.sold} ") index += 1 #Customer menu function def customer_menu(menu): index = 1 for i in menu: print(f"{index}. {i.food:<15} ${i.retail}") index += 1 #Search function for food on menu def search(menu, food): for i in range(len(menu)): if menu[i].food == food.strip(): return i print(menu[i].food + " " + food) print("Item not present in menu") return -1 #Customer order function def place_order(menu): foods = [] quantity = [] total = 0 while 1: print("Enter the number of your choice: ") ch = int(input()) print(f"Enter the quantity you would like to order: ") q = int(input()) menu[ch-1].sold += q total += (menu[ch-1].retail*q) foods.append(menu[ch-1].food) quantity.append(q) print("Would you like to order more? 1. Yes 2. No") con = int(input()) if con == 2: break #Arizona tax applied total = total + total * 0.056 print(f"Total after tax is: ${total:.2f}") print("Enter your desired amount to tip: ") tip = int(input()) total += tip print("\t\t","\u0332".join("Total Bill")," ") #Combine items and quantities to print customer's total bill for food, q in zip(foods, quantity): print(f"\t{food:<15}", f"{q}") tb = ("Total Bill is:") print(f"\t{tb}",f"${total:.2f} ") return menu #Function to remove food from menu def removeItem(menu, food): index = search(menu, food) print(f"{menu[index].food} Deleted From menu") menu = menu[:index] + menu[index + 1:] return menu #Function to add food to menu def addItem(menu): print("Enter name of item to add: ") food = input() print("Enter wholesale price: ") ws = int(input()) print("Enter retail price: ") retail = int(input()) print("Number of items sold in last month: ") sold = int(input()) menu.append(item(food, ws, retail, sold)) #Function for updating menu def update_menu(): print("Enter choice to update") print("1. Name") print("2. wholesale") print("3. Retail") print("4. # of Items sold in last month") #Function to update food on menu def updateitem(menu,food): index = search(menu, food) update_menu() ch = int(input()) if ch == 1: print("Enter new name: ") food = input() menu[index].food = food elif ch == 2: print("Enter new wholsale price: ") ws = int(input()) menu[index].ws = ws elif ch == 3: print("Enter new retail price: ") retail = int(input()) menu[index].retail = retail elif ch == 4: print("Enter new number of items sold in last month: ") sold = int(input()) menu[index].sold = sold return menu #Function to print new menu def Menu(): print("**Enter menu you would like to view**") print("1. Restaurant Manager") print("2. Customer") #Function for manager menu def manager_menu(): print("Manager Menu") print("1. Add Item") print("2. Delete Item") print("3. Update Item") print("4. Print Menu") #Function to write updated menu to file def write_to_file(filename,menu): with open(filename, "w") as f: for i in menu: f.write(f"{i.food},{i.ws},{i.retail},{i.sold} ") if __name__=="__main__": menu=[] #Making list from items in file with open("menu.txt") as f:

for line in f.readlines(): arr=line.rstrip().split(',') menu.append(item(arr[0],int(arr[1]),int(arr[2]),int(arr[3]))) #Loop until user is done while 1: Menu() ch1 = int(input()) #Manager menu if ch1 == 1: manager_menu() ch2 = int(input()) #Add item w/ manager if ch2 == 1: addItem(menu) #Remove item w/ manager elif ch2 == 2: print("Enter name of item to remove: ") food = input() menu = removeItem(menu, food) #Update item w/ manager elif ch2 == 3: print("Enter name of item to update: ") food = input() menu = updateitem(menu, food) #Print the manager menu view elif ch2 == 4: print_menu(menu) else: print("**Check out the menu or proceed to your order**") print("1. View Menu") print("2. Place Order") ch=int(input()) #Print customer menu view if ch == 1: customer_menu(menu) #Begin customer order elif ch == 2: menu = place_order(menu) print(" 1. To Return 2. Exit") ch = int(input()) #Program Exit if ch == 2: break #Write new information to file write_to_file("menu.txt",menu)

-----------------------------------------------------

This is the menu.txt info

eggs,1,4,403 pancakes,1,4,73 waffles,1,4,56 toast,1,2,101 bacon,1,3,402 cheeseburger,4,10,159 potatoes,1,3,201 bagels,1,2,301

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

2.3 Describe the requirements for reasonable accommodation.

Answered: 1 week ago

Question

To find integral of sin(logx) .

Answered: 1 week ago

Question

Know when firms should not offer service guarantees.

Answered: 1 week ago

Question

Recognize the power of service guarantees.

Answered: 1 week ago