Design a parking lot
medium 90 minModel a car park with several levels as classes: vehicles, spaces of different sizes, tickets and a replaceable price rule.
Watch lesson4:48
Sequence
Who calls whom, case by case
The point: one diagram per case that could go differently. If you can draw all seven, the code writes itself.
Case 1
Entry and parking
A car enters
Case 2
What is free?
A sign asks
Cases 3 and 4
Exit, and paying
130 minutes in a medium space
Payments. The lot cannot tell them apart.The card is declined
Case 5
The ticket is lost
Found by plate
Case 6
The lot is full
A polite no
Case 7
An electric car
A space with a charger
Spot.Who takes part
| Participant | Role | In our code |
|---|---|---|
| Driver | Person | Not modelled |
| Gate or panel | Caller with hardware | Outside the lot |
| Lot | Coordinator | ParkingLot |
| Floor | Number, or owner of a lock | Spot.level, later Level |
| Space and pool | The scarce thing and its owner | Spot, SpotPool |
| Ticket | Memory of one stay | Ticket |
| Sign | Reader or listener | free() |
| Payment | Somebody else's machine | Payments |