Pizza Parlor Ordering System

Class Diagram

Pizza Parlor Ordering SystemPizza Parlor Ordering SystemCustomercustomerID: Stringname: Stringphone: Stringaddress: StringplaceOrder(): OrderOrderorderID: StringorderDate: DatetotalPrice: Doublestatus: OrderStatuscalculateTotal(): DoubleaddItem(item: MenuItem, quantity: Integer): voidsetStatus(status: OrderStatus): voidOrderStatusPLACEDPREPARINGBAKINGREADYDELIVEREDCANCELLEDOrderItemquantity: IntegergetSubtotal(): DoubleMenuItemname: Stringprice: DoublegetPrice(): DoublePizzasize: PizzaSizecrust: CrustTypeaddTopping(topping: Topping): voidsetSauce(sauce: Sauce): voidgetPrice(): DoubleSideDishdescription: StringgetPrice(): DoubleDrinkvolume: StringgetPrice(): DoublePizzaSizeSMALLMEDIUMLARGEEXTRA_LARGECrustTypeTHINTHICKSTUFFEDGLUTEN_FREEToppingname: Stringprice: Doublecategory: ToppingCategoryToppingCategoryMEATVEGETABLECHEESESAUCESaucename: Stringdescription: StringAssociation class that linksOrder to MenuItem with quantityCustomizable pizza withmultiple toppings and saucePrice = base price + toppingsAbstract base class forall orderable itemsExample calculation:totalPrice = sum of allOrderItem.getSubtotal()places10..*contains11..*refers to0..*1has10..*has11

Description

A class diagram modeling an online or in-store pizza ordering system where customers can order customizable pizzas, side dishes, and drinks. Demonstrates object-oriented design principles including inheritance, composition, and associations.

Pizza Parlor Ordering System 🍕

This class diagram models a comprehensive pizza ordering system suitable for both online and in-store operations. The design demonstrates fundamental object-oriented programming principles including inheritance, composition, associations, and encapsulation while providing a flexible framework for managing customer orders of customizable pizzas, side dishes, and beverages.

Core Business Classes

Customer Class:

  • Attributes: customerID, name, phone, address
  • Methods: placeOrder()
  • Purpose: Represents the person making the purchase and maintains customer information for delivery and contact purposes
  • Business Logic: Can place multiple orders and maintains order history relationship

Order Class:

  • Attributes: orderID, orderDate, totalPrice, status
  • Methods: calculateTotal(), addItem(), setStatus()
  • Purpose: Central orchestrating class that manages the entire ordering process
  • Business Logic: Aggregates all order items, tracks order progression through different states, and calculates final pricing

OrderItem Class:

  • Attributes: quantity
  • Methods: getSubtotal()
  • Purpose: Association class linking Orders to MenuItems with specific quantities
  • Business Logic: Enables the same menu item to appear multiple times in an order with different quantities

Menu Item Hierarchy (Inheritance)

MenuItem Abstract Base Class:

  • Attributes: name, price
  • Methods: getPrice() (abstract)
  • Purpose: Provides common interface for all orderable items
  • Design Pattern: Template Method pattern for consistent pricing behavior

Pizza Class (extends MenuItem):

  • Attributes: size, crust
  • Methods: addTopping(), setSauce(), getPrice()
  • Purpose: Highly customizable main product with complex pricing logic
  • Composition: Contains multiple Toppings and one Sauce
  • Pricing Logic: Base price + topping costs based on size and selection

SideDish Class (extends MenuItem):

  • Attributes: description
  • Methods: getPrice()
  • Purpose: Represents complementary items like garlic bread, wings, or salads
  • Simple Pricing: Fixed price per item type

Drink Class (extends MenuItem):

  • Attributes: volume
  • Methods: getPrice()
  • Purpose: Beverage options with volume-based pricing
  • Pricing Logic: Price varies by volume (500ml vs 2L)

Pizza Customization Components

Topping Class:

  • Attributes: name, price, category
  • Purpose: Individual pizza ingredients with categorization
  • Categories: Meat, Vegetable, Cheese, Sauce
  • Business Logic: Some toppings incur additional charges, others are included in base price

Sauce Class:

  • Attributes: name, description
  • Purpose: Base sauce selection for pizza
  • Options: Traditional tomato, BBQ, white sauce, pesto
  • Design: Simple composition relationship with Pizza

Enumeration Types

OrderStatus Enum:

  • Values: PLACED, PREPARING, BAKING, READY, DELIVERED, CANCELLED
  • Purpose: Tracks order lifecycle for kitchen management and customer updates

PizzaSize Enum:

  • Values: SMALL, MEDIUM, LARGE, EXTRA_LARGE
  • Purpose: Standardizes pizza size options affecting pricing and topping quantities

CrustType Enum:

  • Values: THIN, THICK, STUFFED, GLUTEN_FREE
  • Purpose: Crust variation options that may affect pricing

ToppingCategory Enum:

  • Values: MEAT, VEGETABLE, CHEESE, SAUCE
  • Purpose: Categorizes toppings for menu organization and dietary restrictions

Relationship Design Patterns

Customer-Order Association:

  • Type: One-to-Many
  • Cardinality: One customer can have multiple orders
  • Business Logic: Enables order history and customer loyalty programs

Order-OrderItem Composition:

  • Type: Strong Composition
  • Cardinality: One order contains many order items
  • Lifecycle: OrderItems cannot exist without their parent Order

OrderItem-MenuItem Association:

  • Type: Many-to-One
  • Purpose: Links quantity-specific order entries to menu catalog items
  • Flexibility: Same MenuItem can appear in multiple OrderItems across different orders

Pizza-Topping Composition:

  • Type: Aggregation
  • Cardinality: One pizza can have multiple toppings
  • Business Logic: Toppings exist independently but are assigned to specific pizzas

Pizza-Sauce Composition:

  • Type: Strong Composition
  • Cardinality: One pizza has exactly one sauce
  • Business Logic: Sauce selection is mandatory for pizza creation

Use Case Implementation Example

Scenario: Customer John orders one large thin-crust pepperoni pizza and one 2L cola

  1. Customer Creation: Customer john = new Customer("John", "555-1234", "123 Main St")
  2. Order Initialization: Order order = john.placeOrder()
  3. Pizza Configuration:
    Pizza pizza = new Pizza(LARGE, THIN)
    pizza.setSauce(new Sauce("Tomato"))
    pizza.addTopping(new Topping("Cheese", 0.00, CHEESE))
    pizza.addTopping(new Topping("Pepperoni", 2.50, MEAT))
    
  4. Drink Selection: Drink cola = new Drink("Cola", "2L")
  5. Order Assembly:
    order.addItem(pizza, 1)
    order.addItem(cola, 1)
    
  6. Total Calculation: order.calculateTotal() aggregates all OrderItem subtotals

Technical Implementation Benefits

Extensibility:

  • Easy addition of new MenuItem types (e.g., Desserts, Appetizers)
  • Flexible topping system accommodates seasonal or specialty ingredients
  • Order status tracking supports complex kitchen workflow management

Maintainability:

  • Clear separation between menu catalog and order instances
  • Abstract MenuItem enables consistent pricing behavior
  • Enumerated types ensure data consistency and validation

Business Intelligence:

  • OrderItem association enables detailed sales analytics
  • Customer-Order relationship supports loyalty program development
  • Topping categorization facilitates inventory management and dietary filtering

Advanced Features Support

Pricing Flexibility:

  • Size-based pricing for pizzas and drinks
  • Optional premium charges for specialty toppings
  • Promotional pricing through method overrides

Order Management:

  • Status tracking for kitchen workflow optimization
  • Customer communication at each order stage
  • Order modification capabilities before preparation begins

Inventory Integration:

  • Topping availability checking
  • Automatic menu item disabling when ingredients unavailable
  • Cost tracking for profit margin analysis

This class diagram provides a robust foundation for a pizza ordering system that can scale from small local operations to large franchise networks while maintaining clean object-oriented design principles and supporting complex business requirements.