Exercise 1: Chaining Coffee, Whip, Milk, Sugar — Possible Solution ==================================================================== BUILDING THE CHAIN IN THE STATED WRAPPING ORDER ------------------------------ "Coffee, Whip, Milk, Sugar" means the base SimpleCoffee is wrapped first by WhipDecorator, then that result is wrapped by MilkDecorator, then that result is wrapped by SugarDecorator (the outermost layer): base = SimpleCoffee() step1 = WhipDecorator(base) step2 = MilkDecorator(step1) step3 = SugarDecorator(step2) HAND CALCULATION ------------------------------ Each decorator's cost() call adds its own amount on top of whatever the wrapped object underneath already reports: base cost = 2.00 + WhipDecorator (0.75) = 2.75 + MilkDecorator (0.50) = 3.25 + SugarDecorator (0.30) = 3.55 VERIFYING AGAINST THE ACTUAL CODE ------------------------------ Running step3.description() and step3.cost() gives: description: 'Coffee, Whip, Milk, Sugar' cost: 3.55 Both match the hand calculation exactly - the description builds up in the same order the objects were wrapped in, and the cost is the sum 2.00 + 0.75 + 0.50 + 0.30 = 3.55. WHY THIS WORKS AS AN ANSWER ------------------------------ The wrapping order is followed literally as stated in the exercise (each named decorator wraps the previous result, left to right), the hand calculation is shown step by step rather than jumping to the total, and the result is confirmed against the actual running code rather than only asserted.