StandardShipping
500 + 100 × kg—Available implementationCustomer’s selectionAppearance
STRATEGY / PRACTICE
Build a replaceable shipping rule. Predict which calculation runs, follow the quote, then add a new delivery method.
YOUR MISSION
Standard shipping works. Now customers want Express—and the ability to switch. Keep the formulas outside Checkout, then add free Pickup without changing its calculation.
Fixed package: 2 kg. Every strategy accepts whole kilograms and returns a nonnegative fee in integer cents.
01 / BUILD A REPLACEABLE BEHAVIOR
Give shipping one shared job, then decide who does it.
Try your own design first. Hints and retries are unlimited.
02 / PREDICT · QUOTE · OBSERVE
Follow the 2 kg package from caller to Checkout and back. Only the selected strategy should calculate its fee.
Choose who calculates the feeDoes Checkout calculate, or delegate?500 + 100 × kg—Available implementationCustomer’s selection1000 + 200 × kg—Available implementationSolid line = this quote’s call path. Dashed lines = available options, not calls to every strategy.
Optional prediction: who will calculate the fee?
Fictional teaching prices. Calculations run synchronously; playback explains the selected execution. No real shipping service is called.
03 / TRANSFER THE IDEA
PickupShipping returns 0 cents for the same package. Which parts need to change?
First verify Standard and Express with a delegating Checkout. This challenge opens when both pass.
No timer and no attempt limit. Try another assembly, use a hint, or reveal the answer whenever it helps.