core practice · system design prompt
Design a parking lot
Model a parking lot with vehicle classes (Car/Bike/Truck), spot sizes, a Lot/Level/Spot hierarchy, and entry/exit. Define the 4-6 classes, their fields, and the park()/leave() interactions.
The mechanism
Object modeling is finding the small set of "things" the system has (usually 4-7) and the actions that happen between them. Prefer composition (this has-a) over inheritance (this is-a). A good model makes the next requirement easy to add.
Expected evidence
Class diagram + the park() flow showing how spot allocation handles size mismatch.
Try this drill in the practice workspace →
Hints when you need them
- Composition over inheritance for vehicle ↔ spot fit.
- Where does pricing live — Spot, Level, or Lot?