Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi! I need help with the following python programming task: Adding on to the restaurant project, define and employ classes for menu items, an order,

Hi! I need help with the following python programming task:

Adding on to the restaurant project, define and employ classes for menu items, an order, and total. Include item price and descriptions. Calculate the subtotal for an order and the total for the order including tax for a defined tax jurisdiction.

My Previous restraunt project:

#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)

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

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago