Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please fix the errors according to the project requirements Project Requirements for the Pizza Store Application Objective: To use an Object-Oriented approach to develop a

Please fix the errors according to the project requirements

Project Requirements for the Pizza Store Application Objective: To use an Object-Oriented approach to develop a comprehensive pizza store application that streamlines recipe management, inventory control, menu customization, and order processing, empowering the store owner to manage their business effectively. Features: 1. Recipe Management: a. Create, edit, and delete pizza recipes. b. Store detailed information about each recipe, including ingredients and quantities. c. Categorize recipes based on pizza type (e.g., vegetarian, meat lovers, specialty). d. Implement search functionality to easily find specific recipes. 2. Ingredient Inventory Management: a. Maintain an inventory of all pizza ingredients. b. Track ingredient usage based on recipe requirements. c. Generate alerts for low-stock ingredients to ensure adequate supply. 3. Standard Menu Management: a. Create and manage a standard menu of pizzas. b. Display each pizza with its name, description, ingredients, and price. c. Categorize pizzas based on type, size, or other relevant criteria. 4. Customer-Customized Pizza Ordering: a. Provide customers with the option to create their own pizzas. b. Offer a selection of pizza bases, sauces, toppings, and additional ingredients. c. Allow customers to customize the quantity of each ingredient. d. Display the total price of the customized pizza based on ingredient choices. 5. Side Dish Management: a. Create and manage a menu of side dishes. b. Display each side dish with its name, description, and price. c. Categorize side dishes based on type (e.g., appetizers, desserts, beverages). 6. Order Processing: a. Capture customer orders for both standard pizzas and customized pizzas. b. Display order details, including pizza selection and side dishes. c. Generate order slips for kitchen staff to prepare orders accurately. 7. User Interface and Accessibility: a. Design a user-friendly interface that is easy to navigate for store owners.

Currently, the store owner relies on paper forms to record customer orders, as illustrated below. This form can serve as a guide for identifying various objects and encapsulating all the necessary information into one or more classes. However, it is important to note that the objects are NOT constrained by the information defined on the order form. Therefore, you should also consider all the additional requirements mentioned previously. To achieve reusability, flexibility, and extensibility, your design should adhere to object-oriented principles and concepts such as Abstraction and Encapsulation. To ensure data persistence, files will be utilized for data storage. Consequently, a 3-layer architecture is recommended, with classes categorized into Presentation, Business, and Data layers.

Dta layer: import os import json class Inventory: def __init__(self): self.ingredients = {} def add_ingredient(self, ingredient, quantity): self.ingredients[ingredient] = self.ingredients.get(ingredient, 0) + quantity self.save_inventory() def use_ingredient(self, ingredient, quantity): if ingredient in self.ingredients and self.ingredients[ingredient] >= quantity: self.ingredients[ingredient] -= quantity self.save_inventory() else: print("Not enough stock for ingredient:", ingredient) def save_inventory(self): try: with open(r'C:\Users\sanji\inventory.txt', 'w') as file: file.write(json.dumps(self.ingredients)) except IOError as e: print("An error occurred while saving the inventory:", e) def load_inventory(self): try: with open(r'C:\Users\sanji\inventory.txt', 'r') as file: self.ingredients = json.loads(file.read()) except IOError as e: print("An error occurred while loading the inventory:", e) class Menu: def __init__(self): self.pizzas = [] self.sides = [] def add_pizza(self, pizza): self.pizzas.append(pizza) self.save_menu() def add_side(self, side): self.sides.append(side) self.save_menu() def save_menu(self): try: with open(r'C:\Users\sanji\menu.txt', 'w') as file: menu_data = { 'pizzas': [pizza.__dict__ for pizza in self.pizzas], 'sides': [side.__dict__ for side in self.sides] } file.write(json.dumps(menu_data)) except IOError as e: print("An error occurred while saving the menu:", e) def load_menu(self): try: with open(r'C:\Users\sanji\menu.txt', 'r') as file: menu_data = json.loads(file.read()) # You need to convert this data back into Pizza and SideDish objects except IOError as e: print("An error occurred while loading the menu:", e)

Business;

image text in transcribedimage text in transcribedimage text in transcribed

pRESENTATION :

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed class Ingredient: def__init_(self, name, quantity=0): self. name = name self.quantity = quantity \# Recipe Class (Base class for pizzas) class Recipe: def _init_(self, name, ingredients=None): if ingredients is None: ingredients =[] self. name = name self.ingredients = ingredients def add_ingredient(self, ingredient): self.ingredients.append(ingredient) def remove_ingredient(self, ingredient_name): self.ingredients = [ingredient for ingredient in self.ingredients if ingredient.name != ingredient_name] \# Pizza Class class Pizza(Recipe): def__init_(self, name, ingredients, base_price): super().__init_(name, ingredients) self.base_price = base_price self.final_price = self.calculate_price( ) def calculate_price(self): return self.base_price +sum(1.75 for _ in self.ingredients) \# CustomPizza Class class Custompizza(Pizza): def__init_(self, base, selected_ingredients, base_price): super()._init_("Custom Pizza", selected_ingredients, base_price) \# SideDish Class def__init_(self, name, price): self. name = name self.price = price \# Order class class order: def__init_(self): self.pizzas = [] self.side_dishes =[] self.total_price =0 def add_pizza(self, pizza): self.pizzas.append(pizza) self.update_total_price() def add_side_dish(self, side_dish): self.side_dishes.append(side_dish) self.update_total_price() def update_total_price(self): self.total_price = sum(pizza.final_price for pizza in self.pizzas) + sum(side.price for side in self.side_dishes) \# Inventory Class class Inventory: def__init_(self): self.stock ={} def add_stock(self, ingredient, quantity): if ingredient in self.stock: self.stock[ingredient].quantity += quantity else: self.stock[ingredient] = Ingredient(ingredient, quantity) def reduce_stock(self, ingredient, quantity): if ingredient in self.stock and self.stock[ingredient].quantity >= quantity: self.stock[ingredient].quantity -= quantity else: else: raise ValueError(f"Not enough stock for \{ingredient\}") def check_stock(self, ingredient): return self.stock.get(ingredient, Ingredient(ingredient, 0)).quantity \# Menu Class class Menu: def__init_(self): self.pizzas =[] self.sides =[] def add_pizza_to_menu(self, pizza): self.pizzas.append(pizza) def add_side_to_menu(self, side): self.sides . append(side) def get_pizza_by_name(self, name): for pizza in self.pizzas: if pizza.name == name: return pizza raise ValueError(f"Pizza named \{name\} not found.") def get_side_by_name(self, name): for side in self.sides: if side. name == name: return side raise ValueError(f"Side named { name } not found.") from business_layer import ( Inventory, Menu, Order, RecipeManager, InventoryManager, MenuManager, OrderManager, from data_layer import DataLayer class PizzastoreCLI: def__init_(self): \# Initialize data and business layers self.data_layer = DataLayer () self.inventory = Inventory(self.data_layer) self.menu = Menu(self.data_layer) self.recipe_manager = RecipeManager ( self.menu) self.inventory_manager = InventoryManager(self.inventory) self.menu_manager = MenuManager(self.menu) self.order_manager = OrderManager(self.data_layer, self.menu, self.inventory) def run(self) : while True: self.display_main_menu() choice = input("Enter the number of your choice: ") if choice ==1 ': self.manage_recipes() elif choice == '2' : self.manage_inventory() elif choice == ' 3 ': self.manage_menu() elif choice == ' 4 ' : self.customize_pizza_order() elif choice == ' 5 ': self.manage_side_dishes() elif choice == '6': self.place_order() elif choice ==7 ': break else: print("Invalid choice. Please try again.") manage_menu(self): while True: print(" Menu Management") print("1. Create New Pizza") print("2. Remove Pizza") print("3. Add New Side Dish") print("4. Remove Side Dish") print("5. Display Menu") print("6. Return to Main Menu") choice = input("Enter the number of your choice: ") if choice == ' 1 ': self.add_new_pizza_to_menu() elif choice == '2' : self.remove_pizza_from_menu() elif choice == ' 3 ': self.add_new_side_dish_to_menu() elif choice ==4 ': self.remove_side_dish_from_menu() elif choice ==5 ': self.display_menu() elif choice == ' 6 ': break else: print("Invalid choice. Please try again.") add_new_pizza_to_menu(self): print(" Adding a New Pizza to Menu") pizza_name = input("Enter pizza name: ") pizza_description = input("Enter pizza description: ") pizza_ingredients = input("Enter pizza ingredients (comma-separated): ").split(', ') pizza_price = float(input("Enter pizza price: ")) pizza_type = input("Enter pizza type (e.g., vegetarian, meat lovers, specialty): ") \# Implement the logic to add the pizza to the menu \# Example: self.menu_manager.add_new_pizza(pizza_name, pizza_description, pizza_ingredients, pizza_price, pizza_type) print(f"Pizza '\{pizza_name\}' added to the menu.") def remove_pizza_from_menu(self): print(" Removing a Pizza from Menu") \# Implement removing a pizza from the menu pizza_name = input("Enter pizza name to remove: ") \# Implement the logic to remove the pizza from the menu \# Example: self.menu_manager.remove_pizza(pizza_name) print(f"Pizza '\{pizza_name\}' removed from the menu.") def add_new_side_dish_to_menu(self): print(" Adding a New Side Dish to Menu") \# Implement adding a new side dish to the menu side_dish_name = input("Enter side dish name: ") side_dish_description = input("Enter side dish description: ") side_dish_price = float(input("Enter side dish price: ")) side_dish_type = input("Enter side dish type (e.g., appetizers, desserts, beverages): ") \# Implement the logic to add the side dish to the menu \# Example: self.menu_manager.add_new_side_dish(side_dish_name, side_dish_description, side_dish_price, side_dish_type) print(f"Side dish '\{side_dish_name \}' added to the menu.") def remove_side_dish_from_menu(self): print("' Removing a side Dish from Menu") \# Implement removing a side dish from the menu side_dish_name = input("Enter side dish name to remove: ") \# Implement the logic to remove the side dish from the menu \# Example: self.menu_manager.remove_side_dish(side_dish_name) print(f"Side dish '\{side_dish_name\}' removed from the menu.") def display_menu(self): print(" Displaying Menu") \# Implement displaying the menu menu_items = self.menu_manager.get_menu_items( ) if not menu_items: print("The menu is empty.") else: print("Menu Items:") for item in menu_items: print(item) def manage_inventory(self): while True: print(" Ingredient Inventory Management") print("1. Maintain Inventory") print("2. Track Ingredient Usage") print("3. Generate Low-Stock Alerts") print("4. Return to Main Menu") choice = input("Enter the number of your choice: ") if choice == '1': self.maintain_inventory() elif choice ==2': self.track_ingredient_usage() elif choice == ' 3 ': self.generate_low_stock_alerts () elif choice == ' 4 ' break det manage_recpes(selt): while True: print(" Recipe Management") print("1. Create New Recipe") print("2. Edit Recipe") print("3. Delete Recipe") print("4. Search Recipes") print("5. Return to Main Menu") choice = input("Enter the number of your choice: ") if choice ==1 ': self.create_recipe() elif choice ==2 ': self.edit_recipe() elif choice ==3 ': self.delete_recipe() elif choice ==4 ': self.search_recipes() elif choice == ' 5 ': break else: print("Invalid choice. Please try again.") def create_recipe(self): print(" creating a New Recipe") \# Implement creating a new recipe pizza_name = input("Enter pizza name: ") pizza_type = input("Enter pizza type (e.g., vegetarian, meat lovers, specialty): ") ingredients = input("Enter ingredients (comma-separated): ").split(', ') quantities = input("Enter quantities (comma-separated): ").split(', ') \# Implement the logic to create a new recipe \# Example: self.recipe_manager.create_recipe(pizza_name, pizza_type, ingredients, quantities) print(f"Recipe for '\{pizza_name\}' created successfully.") def edit_recipe(self): print(" Editing a Recipe") \# Implement editing a recipe pizza_name = input("Enter pizza name to edit: ") new_name = input("Enter new pizza name (press enter to keep the same): ") new_type = input("Enter new pizza type (press enter to keep the same): ") new_ingredients = input("Enter new ingredients (comma-separated, press enter to keep the same): ").split(', ') new_quantities = input("Enter new quantities (comma-separated, press enter to keep the same): ").split(', ') \# Implement the logic to edit a recipe \# Example: self.recipe_manager.edit_recipe(pizza_name, new_name, new_type, new_ingredients, new_quantities) print(f"Recipe for '\{pizza_name\}' edited successfully.") def delete_recipe(self): print(" Deleting a Recipe") \# Implement deleting a recipe pizza_name = input("Enter pizza name to delete: ") \# Implement the logic to delete a recipe \# Example: self.recipe_manager.delete_recipe(pizza_name) print(f"Recipe for '\{pizza_name\}' deleted successfully.") def search_recipes(self): print(" searching Recipes") \# Implement searching for recipes keyword = input("Enter keyword to search: ") results = self.recipe_manager.search_recipes(keyword) if results: print("Search results:") for result in results: print(result) else: print("No recipes found.") def customize_pizza(self): print(" Customize Your Pizza") selected_pizza = input("Select the pizza you want to customize: ") \# Implement logic to offer pizza bases, sauces, toppings, and additional ingredients selected_base = input("Select pizza base (e.g., thin crust, pan): ") selected_sauce = input("Select pizza sauce (e.g., tomato, BBQ): ") \# Offer toppings and additional ingredients available_toppings = ["Cheese", "Pepperoni", "Mushrooms", "Onions", "Peppers", "Sausage", "Bacon"] selected_toppings = self.select_ingredients("Select pizza toppings (comma-separated): ", available_toppings) available_additional_ingredients = ["Olives", "Garlic", "Pineapple", "Spinach", "Jalapenos", "Extra Cheese"] selected_additional_ingredients = self.select_ingredients("Select additional ingredients (comma-separated): ", available_addition \# Allow customers to customize the quantity of each ingredient quantity_dict ={} for ingredient in [selected_base, selected_sauce] + selected_toppings + selected_additional_ingredients: quantity = int(input(f"Enter quantity of \{ingredient \}: ")) quantity_dict[ingredient] = quantity \# Calculate the total price based on ingredient choices total_price = self.menu_manager.calculate_custom_pizza_price(selected_pizza, quantity_dict) \# Display the total price print(f"Total price: \$\{total_price:. 2f}" ) def select_ingredients(self, prompt, available_ingredients): while True: selected_ingredients = input(prompt).split(' , ') selected_ingredients = [ingredient.strip() for ingredient in selected_ingredients] \# Check if all selected ingredients are available if all(ingredient in available_ingredients for ingredient in selected_ingredients): return selected_ingredients else: print("Invalid ingredients selected. Please try again.") def calculate_custom_pizza_price(self, pizza_name, quantity_dict): \# Implement logic to calculate the total price of the customized pizza \# You can use data from the menu and ingredient prices here pass def create_side_dish(self): print(" creating a New Side Dish") \# Implement creating a new side dish side_dish_name = input("Enter side dish name: ") side_dish_description = input("Enter side dish description: ") side_dish_price = float(input("Enter side dish price: ")) \# Implement the logic to create a new side dish \# Example: self.menu_manager.create_side_dish(side_dish_name, side_dish_description, side_dish_price) print(f"Side dish '\{side_dish_name\}' created successfully.") def edit_side_dish(self): print(" diting a Side Dish") \# Implement editing a side dish side_dish_name = input("Enter side dish name to edit: ") new_name = input("Enter new side dish name (press enter to keep the same): ") new_description = input("Enter new side dish description (press enter to keep the same): ") new_price = float(input ("Enter new side dish price (press enter to keep the same): ")) \# Implement the logic to edit a side dish \# Example: self.menu_manager.edit_side_dish(side_dish_name, new_name, new_description, new_price) print(f"Side dish '\{side_dish_name\}' edited successfully.") def delete_side_dish(self): print(" Deleting a side Dish") \# Implement deleting a side dish side_dish_name = input("Enter side dish name to delete: ") \# Implement the logic to delete a side dish \# Example: self.menu manager.delete side dish(side dish name) else: print("Invalid choice. Please try again.") def add_pizza_to_order(self, order): print(" Add Pizza to order") pizza_name = input("Enter pizza name: ") quantity = int(input("Enter quantity: ")) order["pizzas"].append(\{"name": pizza_name, "quantity": quantity } ) def add_side_dish_to_order(self, order): print(" Add Side Dish to order") side_dish_name = input("Enter side dish name: ") quantity = int(input("Enter quantity: ")) order["side_dishes"].append(\{"name": side_dish_name, "quantity": quantity\}) def view_current_order(self, order): print(" current order: ") for pizza in order["pizzas"]: print(f"\{pizza['quantity']\} \{pizza['name']\}(s)") for side_dish in order["side_dishes"]: print(f"\{side_dish['quantity']\} \{side_dish['name']\}(s)") def finalize_order(self, order): print(" Finalize order") \# Implement logic to generate order slips for kitchen staff \# You can use the order details to create the order slips pass if _name_ == "_ main__": pizza_store_cli = PizzastoreCLI( ) pizza_store_cli.run()

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

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions