Design a parking lot system (object-oriented design).
Answer
- Clarify: levels, spot types (motorcycle, compact, large, EV), payment, entry/exit gates.
- Classes:
ParkingLot (levels, gates), Level (spots), ParkingSpot (type, is_free), Vehicle with a size, Ticket (spot, entry time), PricingStrategy. - Spot assignment strategy (nearest free, by type) behind an interface.
- Concurrency: two cars must never get the same spot (lock or atomic DB update).
- Show SOLID: pricing as a Strategy, free-spot displays as Observers.
Practice this question in Repaso