Exercise 2: A Conditional NewCustomerDiscount Strategy — Possible Solution ==================================================================== THE NEW STRATEGY ------------------------------ class NewCustomerDiscount: def apply(self, total): return 5 if total > 50 else 0 Follows the exact same one-method apply(total) interface as VipDiscount, LoyaltyDiscount, and NoDiscount - the only difference is that its own logic is conditional on its input, something none of the three existing strategies needed to do. Nothing about Order or OrderBuilder had to change to accommodate this - both already just call self.discount_strategy.apply(self.items_total) without caring what happens inside. VERIFYING THE OVER-$50 CASE ------------------------------ order_over = OrderBuilder().items_total(80).weight(4).discount_strategy(NewCustomerDiscount()).build() over-50 total: 77.0 manual: 80 - 5 + 4*0.5 = 77.0 VERIFYING THE UNDER-$50 CASE ------------------------------ order_under = OrderBuilder().items_total(30).weight(4).discount_strategy(NewCustomerDiscount()).build() under-50 total: 32.0 manual: 30 - 0 + 4*0.5 = 32.0 Both cases match their hand calculations exactly - the $5 discount correctly applies only when items_total exceeds $50, and correctly does not apply otherwise. WHY THIS CONFIRMS THIS CHAPTER'S OWN CLAIM ------------------------------ This exercise adds a genuinely new business rule (a threshold-based discount, unlike any of the three existing flat-rate/percentage strategies) without touching Order, OrderBuilder, or any of the three existing discount classes at all - directly demonstrating this chapter's own "Where This Wasn't Used" reasoning that Strategy was the right tool: new discount rules are added by writing one new, self-contained class, not by editing shared code. WHY THIS WORKS AS AN ANSWER ------------------------------ The new strategy matches the established apply(total) interface exactly while adding genuinely new conditional logic, and both branches of that condition are verified separately against hand calculations rather than only checking one case.