Part 1 of 6 · 1 min read
Why this page comes seventh in Level 7
In this module you will
- Turn a ride-hailing question into requirements for drivers, riders, trips and fares.
- Model a trip as a state machine with only the legal moves allowed.
- Rank drivers with a replaceable matching rule, and reserve one safely when many riders ask at once.
- Price a trip with a fare rule that can be wrapped in a surge multiplier.
- Say what changes when the same design must run for a whole city.
Cab booking combines three earlier ideas in one design: the state pattern of Level 4, module 3, the strategy pattern of Level 4, module 1, and the check-then-act race of Level 5, module 3. The race here is two riders being given the same driver. No book was supplied for this track, so the content is common practice, not from the books. The Java code was compiled and run before it was written here. Numbers marked "made up" only show the idea.