CSC110 / lectures / Simplified / Building a Simulation / entities.py
entities.py
Raw
from __future__ import annotations
from dataclasses import dataclass
import datetime
from typing import Optional


@dataclass
class Vendor:
    name: str
    address: str
    menu: dict[str, float]
    location: tuple[float, float]  # (latitude, longitude)
@dataclass
class Customer:
    name: str
    location: tuple[float, float]
@dataclass
class Order:
    customer: Customer
    vendor: Vendor
    food_items: dict[str, int]
    start_time: datetime.datetime
    courier: Optional[Courier] = None
    end_time: Optional[datetime.datetime] = None
@dataclass
class Courier:
    """A person who delivers food orders from vendors to customers.
    Representation Invariants:
        - (self.current_order is None) or (self.current_order.courier is self)
    """
    name: str
    location: tuple[float, float]
    current_order: Optional[Order] = None