Skip to content

Elevator System — Detailed#

classDiagram
  direction TB

  class ElevatorSystem {
    -cars: List~Car~
    -dispatcher: Dispatcher
    -listeners: List~Observer~
    +callFloor(floor, dir)
    +request(carId, dest)
  }

  class Car {
    -id: int
    -floor: int
    -dir: Direction
    -state: CarState
    -queue: Stops
    -capacity: int
    -load: int
    +addStop(floor)
    +tick()
  }

  class CarState {
    <<enumeration>>
    IDLE
    MOVING_UP
    MOVING_DOWN
    DOORS_OPEN
    OUT_OF_SERVICE
  }

  class Direction {
    <<enumeration>>
    UP
    DOWN
    IDLE
  }

  class Request {
    -from: int
    -to: int
    -dir: Direction
    -priority: int
    -ts
  }

  class Dispatcher {
    <<interface>>
    +assign(req, cars) Car
  }
  class NearestCar
  class ScanLook
  class GroupControl

  class Door
  class Sensor
  class WeightSensor
  class EmergencyButton
  class FirefighterMode

  ElevatorSystem "1" *-- "many" Car
  ElevatorSystem --> Dispatcher
  Dispatcher <|.. NearestCar
  Dispatcher <|.. ScanLook
  Dispatcher <|.. GroupControl
  Car --> CarState
  Car --> Direction
  Car *-- Door
  Car *-- Sensor
  Car *-- WeightSensor
  Car *-- EmergencyButton
  Car *-- FirefighterMode
  ElevatorSystem --> Request

Scheduling#

  • Nearest Car: simplest; greedy.
  • SCAN / LOOK (elevator algorithm): serve all in current direction before switching.
  • Group control: optimize across cars (most production buildings).

Glossary & fundamentals#

Concepts referenced in this design. Each row links to its canonical page; the tag column shows whether it is a high-level (HLD) or low-level (LLD) concept.

Tag Concept What it is Page
LLD Behavioural patterns Strategy, Observer, State, Command, Chain behavioral-patterns