Exercise 2: Adding a HotChocolate Subclass — Possible Solution ==================================================================== THE NEW SUBCLASS ------------------------------ class HotChocolate(CaffeineBeverage): def brew(self): return 'Melting chocolate into hot milk' def add_condiments(self): return 'Adding whipped cream and marshmallows' Follows this chapter's own Tea/Coffee template exactly - HotChocolate overrides only the two steps CaffeineBeverage declares as NotImplementedError (brew and add_condiments), and inherits boil_water/pour_in_cup/prepare_recipe completely unmodified. VERIFYING THE SHARED STEPS ARE IDENTICAL ACROSS ALL THREE ------------------------------ Tea: ['Boiling water', 'Steeping the tea', 'Pouring into cup', 'Adding lemon'] Coffee: ['Boiling water', 'Dripping coffee through filter', 'Pouring into cup', 'Adding sugar and milk'] HotChocolate: ['Boiling water', 'Melting chocolate into hot milk', 'Pouring into cup', 'Adding whipped cream and marshmallows'] boil_water shared across all three: True pour_in_cup shared across all three: True Step 1 and step 3 are confirmed identical across all three subclasses, not just between the two this chapter already checked - the same inherited method runs unmodified for a third, brand-new subclass with no changes needed anywhere in CaffeineBeverage itself. VERIFYING THE OVERRIDDEN STEPS GENUINELY DIFFER ------------------------------ HotChocolate brew differs from Tea and Coffee: True HotChocolate add_condiments differs from Tea and Coffee: True HotChocolate's own brew and add_condiments strings are confirmed different from both Tea's and Coffee's versions of those same two steps. WHY THIS WORKS AS AN ANSWER ------------------------------ The new subclass overrides exactly the two abstract steps the base class requires and nothing else, the two shared steps are verified identical across all three subclasses (not assumed to still hold just because they held for two), and the two genuinely-different steps are verified to differ from both existing subclasses, not just one.