Preparing your design workspace

Loading the problem and your saved attempt…

Design a Ticketed Parking Lot with Defragmentation

Model parking, retrieval by stable ticket, and nightly compaction of cars toward one end of the lot.

Design the low-level object model and interfaces for a Ticketed Parking Lot with Defragmentation.

For this exercise, assume one linear lot of numbered spots, one car per spot, and a stable opaque ticket returned at park time. Retrieval uses the ticket even after nightly defragmentation moves cars.

Defragmentation runs while new park and retrieve commands are paused and must preserve every active ticket-to-car mapping.

For invalid states, return explicit outcomes for: lot full; duplicate VehicleId; unknown or already redeemed ticket; maintenance in progress. Preserve this invariant: Each parked VehicleId has one active ParkingTicket and one occupied spot; ticket identity remains stable when a vehicle moves.