Preparing your design workspace

Loading the problem and your saved attempt…

Design a Smallest-Fit Parking Lot with EV Charging

Model a sized parking lot that gives each vehicle the smallest fitting spot, then extend it with charging spots and fallbacks.

For this exercise, assume one parking lot has numbered spots in three sizes, small, medium, and large, and vehicles come in the same three sizes. A vehicle fits a spot of its own size or larger.

When a vehicle parks, the lot gives it the smallest free spot that fits, choosing the lowest spot number among spots of that size, and returns a ticket. A vehicle that is already parked, or a vehicle with no free spot that fits, is rejected without changing anything.

When the vehicle leaves with its ticket, exactly its spot becomes free again; an unknown or already-used ticket is rejected. Design the objects, responsibilities, interfaces, and interactions, then implement park and leave in memory. A final follow-up adds electric-vehicle charging spots.

Pricing, payment, reservations, multiple lots, entrances and exits, persistence, and user interfaces are outside scope.