Requirements

  1. System supports three vehicle types: Motorcycle, Car, Large Vehicle
  2. When a vehicle enters, system automatically assigns an available compatible spot
  3. System issues a ticket at entry.
  4. When a vehicle exits, user provides ticket ID
    • System validates the ticket
    • Calculates fee based on time spent (hourly, rounded up)
    • Frees the spot for next use
  5. Pricing is hourly with same rate for all vehicles
  6. System rejects entry if no compatible spot is available
  7. System rejects exit if ticket is invalid or already used

Out of scope:

  • Payment processing
  • Physical gate hardware
  • Security cameras or monitoring
  • UI/display systems
  • Reservations or pre-booking

Entities & Relationship

  1. ParkingLot - the main orchestrator, handles entry and exits, fare calculation, ticket validation, checks spot availability
  2. ParkingSpot - holds information like id, spot type, availability
  3. Ticket - id, entry timestamp for fare calculation, parking spot id, vehicle type(?)

Class Design

SpotType
  MOTORCYCLE
  CAR
  LARGE
VehicleType
  MOTORCYCLE
  CAR
  LARGE 
ParkingSpot
  - id
  - spot_type
  - status
  
  + get_id()
  + get_spot_type()
  + get_status()
  + mark_free()
  + mark_occupied()
Ticket
  - id
  - parking_spot_id
  - entry_timestamp
    
  + get_id()
  + get_parking_spot_id()
  + get_entry_timestamp()
ParkingLot
  - active_tickets : map<ticket_id, Ticket>
  - parking_spots : list<ParkingSpot>
  - hourly_rates : map<VehicleType, rate>
  
  + enter(VehicleType) -> Ticket
  + exit(ticket_id) -> long