Design an Object-Oriented system for a Parking Lot.

Code Playground
JavaScript (V8)
Loading...
Console Output
// Output will appear here...
// For React: ReactDOM.createRoot(rootElement).render(<App />);
Recommended Answer

OO Design Scenario:

1. Classes: ParkingLot, Level, ParkingSpot, Vehicle (Abstract), Car, Motorcycle, Ticket.

2. Logic:

* ParkingLot has many Levels.

* Level has many ParkingSpots (Compact, Large, Motorcycle).

* entry(Vehicle) -> finds spot, issues Ticket.

* exit(Ticket) -> calculates fee, frees spot.

3. Concurrency: Need to handle multiple cars entering simultaneously (locking).