Skip to content

Parking Lot — Simple#

Problem statement (interviewer prompt)

Design a parking lot system: model the lot, spots of different sizes (motorcycle / car / van), the entry / exit gates, ticketing, real-time availability, pricing by duration, and reservations. Focus on the OO class model and the state transitions.

classDiagram
  class ParkingLot {
    +levels : List~Level~
    +park(v: Vehicle) Ticket
    +unpark(t: Ticket) double
  }
  class Level {
    +slots : List~Slot~
    +findFreeSlot(v) Slot
  }
  class Slot {
    +id
    +type : SlotType
    +occupied : boolean
  }
  class Vehicle {
    <<abstract>>
    +regNo
    +type : VehicleType
  }
  ParkingLot "1" *-- "many" Level
  Level "1" *-- "many" Slot
  Vehicle <|-- Car
  Vehicle <|-- Bike
  Vehicle <|-- Truck