Assignment

import math
import csv

"""Represents a single item on the restaurant menu."""
class MenuItem:
    def __init__(self, name, price, category, sizes):
        """
        name: str
        price: float (base price, usually 'medium')
        category: str (e.g., 'Appetizers', 'Entrees', 'Desserts', 'Beverages')
        sizes: dict or None, e.g. {'small': -1, 'medium': 0, 'large': 1}
        """
        self.name = name
        self.price = float(price)
        self.category = category
        self.sizes = sizes

    def get_price(self):
        """Return the adjusted price based on size."""
        pass

    def __str__(self):
        """Return a user-friendly representation of the item."""
        pass

"""Holds all menu items, organized by category."""
class Menu:
    def __init__(self):
        # Each category stores a list of MenuItem objects
        self.categories = {
            "Appetizers": [],
            "Entrees": [],
            "Desserts": [],
            "Beverages": []
        }

    def add_item(self, item: MenuItem):
        """Add a MenuItem to the appropriate category."""
        pass

    def show_category(self, category_name):
        """Print all items in a category with numbers."""
        pass

    def get_item_by_number(self, category_name, number):
        """
        Return a MenuItem given a category and a 1-based item number.
        Assumes the number is valid.
        """
        pass

"""Represents a selected item in the customer's order."""
class OrderItem:
    def __init__(self, menu_item, quantity, size):
        self.menu_item = menu_item
        self.quantity = quantity
        self.size = size
        self.line_total = 0.0

    def calculate_line_total(self):
        """Recalculate the line total based on quantity and size."""
        pass

    def __str__(self):
        pass

"""Represents the entire order (multiple OrderItem objects)."""
class Order:
    def __init__(self):
        self.items = []          # list of OrderItem
        self.coupon_type = None  # 'percent' or 'fixed' or None
        self.coupon_amount = 0.0
        self.tip_percent = 0.0
        self.delivery = False

    def add_item(self):
        """Create and add an OrderItem to the list."""
        pass

    def remove_item(self):
        """Remove first matching item from the order by name."""
        pass

    def update_quantity(self):
        """Update quantity (and line_total) for the given item."""
        pass

    def view_order(self):
        """Print a nicely formatted view of the order."""
        pass

    def calculate_subtotal(self):
        """Return the subtotal before coupons, tax, tip, or delivery."""
        pass

    def apply_coupon(self):
        """Apply coupon to the subtotal and return discounted subtotal."""
        pass

    def calculate_total_with_tax_and_tip(self):
        """
        Apply coupon, tax, tip, and delivery fee.
        Returns final total.
        """
        pass

    def save_to_csv(self):
        """Save the order to a CSV file (Item Name,Quantity,Price)."""
        pass

    def view_file(self):
        """Display contents of the CSV file."""
        pass

"""Ties together restaurant info, menu, and a current order."""
class Restaurant:
    def __init__(self, name, location, url):
        self.name = name
        self.location = location
        self.url = url
        self.menu = Menu()
        self.current_order = Order()

    def display_info(self):
        pass

    def order_from_category(self, category_name, allow_sizes=False):
        """
        Show category, ask the user if they want to order,
        ask which item number, size (if beverage), and quantity,
        then add to current_order.
        """
        pass

    def modify_order(self):
        """
        Let the user choose to delete an item or change its quantity.
        """
        pass

    def place_order(self):
        """
        Show subtotal, ask about coupon, tip, pickup/delivery,
        then show final total and save to CSV.
        """
        pass

    def view_order_file(self):
        """Call the Order method to view the CSV file."""
        pass


def create_menu():
    """
    Add menu items
    """
    pass


def main():
    while True:
        print("\n=== OOP Restaurant Ordering System ===")
        print("1. View restaurant information")
        print("2. Order appetizers")
        print("3. Order entrees")
        print("4. Order desserts")
        print("5. Order beverages")
        print("6. View current order")
        print("7. Modify order")
        print("8. Place order")
        print("9. View order file")
        print("0. Exit")

        choice = input("Choose an option: ").strip()

        if choice == "1":
            restaurant.display_info()
        elif choice == "2":
            restaurant.order_from_category("Appetizers")
        elif choice == "3":
            restaurant.order_from_category("Entrees")
        elif choice == "4":
            restaurant.order_from_category("Desserts")
        elif choice == "5":
            restaurant.order_from_category("Beverages")
        elif choice == "6":
            restaurant.current_order.view_order()
        elif choice == "7":
            restaurant.modify_order()
        elif choice == "8":
            restaurant.place_order()
        elif choice == "9":
            restaurant.view_order_file()
        elif choice == "0":
            print("Goodbye!")
            break
        else:
            print("Invalid choice. Please try again.")

main()

Last updated