Design a Parking Lot with Flexible Fees
Model a parking journey whose versioned pricing policies support complex hourly fees without destabilizing active sessions.
Design the object model and contracts for a parking lot, with particular attention to complex parking-fee and hourly-rate calculation.
For this exercise, assume a driver enters with a motorcycle, car, or oversized vehicle; the lot assigns one compatible free spot and creates an active parking session. The driver may request a fee quote and later close the session, after which that spot becomes available exactly once.
Each session pins the immutable rate-plan version active at entry. A rate plan may combine a grace period, progressive hourly bands, a vehicle-category surcharge, and an optional daily cap. Duration is measured from UTC instants, each started hour rounds up after the grace period, and money uses integer cents.
Unknown tickets, an exit before entry, and a second close must have explicit outcomes; a repeated close returns the stored final fee without another release.
Use a design-only format. Payment processing, reservations, persistence, multi-lot routing, display boards, and user-interface concerns are outside scope. Leave allocation and pricing implementation choices open, but make the pricing variation boundary, lifecycle invariants, and testability clear.