Using this code: #class item represents each item in the menu class Foodchoice: # constructor to initialize variables def __init__(self,name,wholesale,retail,Num_of_times): self.name=name self.wholesale=wholesale self.retail=retail self.no_of_times=Num_of_times # returns the item in string format def __str__(self): return f"{self.name} {self.wholesale} {self.retail} {self.no_of_times}" #printing the menu to restaurant manager def print_menu(menu): index=1 for i in menu: print(f"{index}. {i}") index+=1 #function to print the menu to customer def customer_menu(menu): index=1 for i in menu: print(f"{index}. {i.name} {i.retail}") index+=1 #Function to search for a item in menu with the given name def search(menu,name): for i in range(len(menu)): if menu[i].name==name.strip(): return i print(menu[i].name+" "+name) print("Item not present in menu") return -1 #Function to place order by the customer def order(menu): names=[] quantity=[] total=0 while 1: print("Enter choice") ch=int(input()) print("Enter Quantity") q=int(input()) menu[ch-1].no_of_times+=q total+=(menu[ch-1].retail*q) names.append(menu[ch-1].name) quantity.append(q) print("Do you want to continue\n1) yes\n2) no") con=int(input()) if con==2: break #5% tax on the total amount total= total + total*0.05 print("Add Tip") tip=int(input()) #Adding tip to the total total+=tip #printing customer bill print("\t\tBILL\n") #use zip function to combine names and quantity array into a single array of tuples for name,q in zip(names,quantity): print(f"{name} {q}") print("Total Bill is "+str(total)) return menu #Function to remove item from the menu def deleteItem(menu,name): index=search(menu,name) print(f"{menu[index].name} Deleted From menu") menu=menu[:index]+menu[index+1:] return menu #function to add item''' def addItem(menu): print("Enter name") name=input() print("Enter wholesale price") wholesale=int(input()) print("Enter retail price") retail= int(input()) print("Number of items") no_of_times=int(input()) menu.append(Foodchoice(name,wholesale,retail,no_of_times)) #Function to print the update menu def update_menu(): print("Enter choice to update") print("1) Name") print("2) wholesale") print("3) Retail") print("4) Num of Items") #Function to update item in the menu''' def updateitem(menu,name): index=search(menu,name) update_menu() ch=int(input()) if ch==1: print("Enter new name") name=input() menu[index].name=name elif ch==2: print("Enter new wholsale price") wholesale=int(input()) menu[index].wholesale=wholesale elif ch==3: print("Enter new retail price") retail=int(input()) menu[index].retail=retail elif ch==4: print("Enter new number of items") no=int(input()) menu[index].no_of_times=no return menu #Function to print the main menu def Menu(): print("***********MENU********") print("Select your Occupation") print("1 . Restaurant Manager") print("2 . Customer") #Function to print the restaurent manager display def restaurent_manager_menu(): print("Restaurant Manager Menu") print("1. Add Item") print("2. Delete Item") print("3. Update Item") print("4. Print Menu") #Function to write the updated menu in the file def write_to_file(filename,menu): with open(filename, "w") as f: for i in menu: f.write(f"{i.name},{i.wholesale},{i.retail},{i.no_of_times}\n") if __name__=="__main__": #array to store list of items menu=[] #reading items from file into list with open("menu.txt") as f: for line in f.readlines(): arr=line.rstrip().split(',') menu.append((arr[0],int(arr[1]),int(arr[2]),int(arr[3]))) #While the user does not exit keep looping while 1: ''' display the main menu ''' Menu() ''' Enter choice ''' ch1=int(input()) ''' if choice is 1 print restaurent manager display''' if ch1==1: restaurent_manager_menu() ''' Enter choice ''' ch2=int(input()) if ch2==1: ''' add item in the menu''' addItem(menu) elif ch2==2: ''' if choice is 2 remove a item ''' print("Enter name of dish to remove ") name=input() menu=deleteItem(menu,name) elif ch2==3: ''' if choice is 3 update the item''' print("Enter name of item to update") name=input() menu=updateitem(menu,name) elif ch2==4: ''' if choice is 4 print the menu''' print_menu(menu) else: print("*****Customer's Menu******") print("1. View Menu") print("2. Place Order") ch=int(input()) if ch==1: '''Display customers menu''' customer_menu(menu) elif ch==2: ''' invoke place order menu ''' menu=order(menu) print("1. To Continue\n 2.Exit") ch=int(input()) ''' if choice is 2 exit ''' if ch==2: break '''Store the updated menu into the file menu.txt ''' write_to_file("menu.txt", menu)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Using this code:

#class item represents each item in the menu
class Foodchoice:
# constructor to initialize variables
def __init__(self,name,wholesale,retail,Num_of_times):
self.name=name
self.wholesale=wholesale
self.retail=retail
self.no_of_times=Num_of_times
# returns the item in string format
def __str__(self):
return f"{self.name} {self.wholesale} {self.retail} {self.no_of_times}"

#printing the menu to restaurant manager
def print_menu(menu):
index=1
for i in menu:
print(f"{index}. {i}")
index+=1
#function to print the menu to customer
def customer_menu(menu):
index=1
for i in menu:
print(f"{index}. {i.name} {i.retail}")
index+=1
#Function to search for a item in menu with the given name
def search(menu,name):
for i in range(len(menu)):
if menu[i].name==name.strip():
return i
print(menu[i].name+" "+name)
print("Item not present in menu")
return -1
#Function to place order by the customer
def order(menu):

names=[]
quantity=[]
total=0
while 1:
print("Enter choice")
ch=int(input())
print("Enter Quantity")
q=int(input())
menu[ch-1].no_of_times+=q
total+=(menu[ch-1].retail*q)
names.append(menu[ch-1].name)
quantity.append(q)
print("Do you want to continue\n1) yes\n2) no")
con=int(input())
if con==2:
break
#5% tax on the total amount
total= total + total*0.05
print("Add Tip")
tip=int(input())
#Adding tip to the total
total+=tip
#printing customer bill
print("\t\tBILL\n")
#use zip function to combine names and quantity array into a single array of tuples

for name,q in zip(names,quantity):
print(f"{name} {q}")
print("Total Bill is "+str(total))
return menu
#Function to remove item from the menu
def deleteItem(menu,name):
index=search(menu,name)
print(f"{menu[index].name} Deleted From menu")
menu=menu[:index]+menu[index+1:]
return menu
#function to add item'''
def addItem(menu):
print("Enter name")
name=input()
print("Enter wholesale price")
wholesale=int(input())
print("Enter retail price")
retail= int(input())
print("Number of items")
no_of_times=int(input())
menu.append(Foodchoice(name,wholesale,retail,no_of_times))
#Function to print the update menu
def update_menu():
print("Enter choice to update")
print("1) Name")
print("2) wholesale")
print("3) Retail")
print("4) Num of Items")
#Function to update item in the menu'''
def updateitem(menu,name):
index=search(menu,name)
update_menu()
ch=int(input())
if ch==1:
print("Enter new name")
name=input()
menu[index].name=name
elif ch==2:
print("Enter new wholsale price")
wholesale=int(input())
menu[index].wholesale=wholesale
elif ch==3:
print("Enter new retail price")
retail=int(input())
menu[index].retail=retail
elif ch==4:
print("Enter new number of items")
no=int(input())
menu[index].no_of_times=no
return menu
#Function to print the main menu
def Menu():
print("***********MENU********")
print("Select your Occupation")
print("1 . Restaurant Manager")
print("2 . Customer")
#Function to print the restaurent manager display
def restaurent_manager_menu():
print("Restaurant Manager Menu")
print("1. Add Item")
print("2. Delete Item")
print("3. Update Item")
print("4. Print Menu")
#Function to write the updated menu in the file
def write_to_file(filename,menu):
with open(filename, "w") as f:
for i in menu:
f.write(f"{i.name},{i.wholesale},{i.retail},{i.no_of_times}\n")

if __name__=="__main__":
#array to store list of items
menu=[]
#reading items from file into list
with open("menu.txt") as f:

for line in f.readlines():
arr=line.rstrip().split(',')
menu.append((arr[0],int(arr[1]),int(arr[2]),int(arr[3])))
#While the user does not exit keep looping
while 1:
''' display the main menu '''
Menu()
''' Enter choice '''
ch1=int(input())
''' if choice is 1 print restaurent manager display'''
if ch1==1:
restaurent_manager_menu()
''' Enter choice '''
ch2=int(input())
if ch2==1:
''' add item in the menu'''
addItem(menu)
elif ch2==2:
''' if choice is 2 remove a item '''
print("Enter name of dish to remove ")
name=input()
menu=deleteItem(menu,name)
elif ch2==3:
''' if choice is 3 update the item'''
print("Enter name of item to update")
name=input()
menu=updateitem(menu,name)
elif ch2==4:
''' if choice is 4 print the menu'''
print_menu(menu)
else:

print("*****Customer's Menu******")
print("1. View Menu")
print("2. Place Order")
ch=int(input())

if ch==1:
'''Display customers menu'''
customer_menu(menu)
elif ch==2:
''' invoke place order menu '''
menu=order(menu)

print("1. To Continue\n 2.Exit")
ch=int(input())
''' if choice is 2 exit '''
if ch==2:
break
'''Store the updated menu into the file menu.txt '''
write_to_file("menu.txt", menu)

 

 

Add an application of threads to your restaurant project. Include a class that inherits threading and then allows the program to move on to other operations. Create threads for a log file. For example, when an object is created log it out with threads. Also add a log thread that is started each time an order object is added to the totals object. Don't let the program complete before all the logs are closed.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY