Hi All,
I am apologizing in advance if it wastes your time. Because it's not a question regarding any topic. It is for my improvement. Experts can suggest to me what would be the better option that could be used. I believe Feedbacks are the best way to improve oneself.
So here is my project. Its a simple project of a restaurant.
Flow:
Code as user whether he would like to order something?
If it's Yes --> The code displays the menu
---> Ask for the food items he would like to place?
---> Once the user is done with the order. A final bill is displayed.
Restaurant.py
I am apologizing in advance if it wastes your time. Because it's not a question regarding any topic. It is for my improvement. Experts can suggest to me what would be the better option that could be used. I believe Feedbacks are the best way to improve oneself.
So here is my project. Its a simple project of a restaurant.
Flow:
Code as user whether he would like to order something?
If it's Yes --> The code displays the menu
---> Ask for the food items he would like to place?
---> Once the user is done with the order. A final bill is displayed.
Restaurant.py
""" This module is a restaurant program. Ask user input to place an order. Provide multiple options to user to choose. """ class TajRestaurant: """ Class TajRestaurant ask user input to place an order """ # class variable tables_occupied = 0 max_tables = 10 menu = {'burger': {'hamburger': 5, 'chicken': 7}, 'pizza': {'cheese': 6, 'veg': 8}} def __init__(self): if TajRestaurant.max_tables < 10: TajRestaurant.tables_occupied += 1 self.bill_amount = 0 self.print_menu() self.take_order() else: print(" Sorry we are full. Kindly wait") def get_status(self): msg = input(" Would you like to place an order anything?? \n").lower() if msg == "yes": return True elif msg == "no": return False else: print("Invalid Input. ") exit() def print_menu(self): for food, sub_food in TajRestaurant.menu.items(): for items, price in sub_food.items(): print(items + " " + food + '\n =====================', "Price: $", price) def take_order(self): status = self.get_status() total_order = [] while status: user_order = input(" What would you like to have? ").lower() food_status = self.check_item_availability(user_order) if food_status: # collect all the food items to bill total_order.append(user_order) status = self.get_status() if status == False: self.cashier(total_order) break if status == False: print("Thanks you for your visit ") def check_item_availability(self, food_item): fstatus = False for _, sub_food in TajRestaurant.menu.items(): if food_item in sub_food: fstatus = True break else: fstatus = False if fstatus: print("Item Available ") else: print("Unavailable !") return fstatus def get_price(self, ordered_food): for _, sub_food in TajRestaurant.menu.items(): for user_food in ordered_food: if user_food in sub_food: self.bill_amount += int(sub_food[user_food]) return self.bill_amount def cashier(self, user_food): bill = self.get_price(user_food) print("Your bill is: $" + str(bill)) print(" Welcome to Taj Restaurant !!!")