In this article, we will explore the object-oriented design and implementation of a Restaurant Management System using Python3.
This system will handle various aspects such as table reservations, order processing, and kitchen management.
The Online Shopping System should:
- Table Reservation Management: Handle booking and management of tables.
- Order Management: Process food orders from customers.
- Inventory Management: Keep track of kitchen inventory and supplies.
- Billing System: Generate and manage customer bills.
- Reserving Tables
- Placing and Processing Food Orders
- Managing Inventory
- Generating and Processing Bills
RestaurantManagementSystem
: Manages the entire system.Table
: Represents a dining table in the restaurant.Order
: Manages a customer's food order.Inventory
: Keeps track of kitchen inventory.Bill
: Represents a customer's bill.
Represents a dining table in the restaurant.
class Table:
def __init__(self, table_id: int, seating_capacity: int):
self.table_id = table_id
self.seating_capacity = seating_capacity
self.is_reserved = False
def reserve_table(self):
self.is_reserved = True
def release_table(self):
self.is_reserved = False
Manages a food order.
class Order:
def __init__(self, order_id: int):
self.order_id = order_id
self.items = {} # Item name and quantity
def add_item(self, item_name: str, quantity: int):
if item_name in self.items:
self.items[item_name] += quantity
else:
self.items[item_name] = quantity
Tracks kitchen inventory and supplies.
class Inventory:
def __init__(self):
self.stock = {} # Item name and quantity in stock
def update_stock(self, item_name: str, quantity: int):
self.stock[item_name] = quantity
def is_item_available(self, item_name: str, quantity_needed: int) -> bool:
return self.stock.get(item_name, 0) >= quantity_needed
def get_stock(self, item_name: str) -> int:
return self.stock.get(item_name, 0)
Represents a customer's bill.
class Bill:
def __init__(self, bill_id: int, order: Order):
self.bill_id = bill_id
self.order = order
self.total_amount = self.calculate_total(order)
def calculate_total(self, order: Order) -> float:
# Placeholder for total calculation
# Should fetch prices for each item and sum them up
return 0.0
Main class that manages the restaurant operations.
class RestaurantManagementSystem:
def __init__(self):
self.tables = []
self.inventory = Inventory()
self.initialize_tables()
def initialize_tables(self):
for i in range(1, 11): # Assuming the restaurant has 10 tables
self.tables.append(Table(i, i + 2)) # Example: Table ID 1 with 3 seats, etc.
def reserve_table(self, table_id: int):
for table in self.tables:
if table.table_id == table_id and not table.is_reserved:
table.reserve_table()
return table
return None # No table available or invalid tableId
def place_order(self, order_id: int, items: dict):
new_order = Order(order_id)
for item_name, quantity in items.items():
if self.inventory.is_item_available(item_name, quantity):
new_order.add_item(item_name, quantity)
self.inventory.update_stock(item_name, self.inventory.get_stock(item_name) - quantity)
else:
print(f"Item not available: {item_name}")
return new_order
def main():
system = RestaurantManagementSystem()
table = system.reserve_table(1)
if table:
print(f"Reserved table {table.table_id} with seating capacity of {table.seating_capacity}")
else:
print("Failed to reserve table.")
order = system.place_order(1, {'Pasta': 2, 'Salad': 3})
print(f"Order placed with ID {order.order_id} for items: {order.items}")
if __name__ == "__main__":
main()