Exercise

Extending the Cooking Capabilities

The child class can extend the functionality of the parent by adding further public methods with names that are different to those available in the parent class.

Public methods can call other public methods by prefixing their name with self$.

Instructions

100 XP

A microwave oven has been predefined in your workspace.

  • Extend the definition of the fancy microwave oven class to include a public element.
  • Add a public cook_baked_potato() method.
    • This should take no arguments.
    • In the body, it should call its own cook() method for 3 seconds.
  • Create a FancyMicrowaveOven object and assign it to a_fancy_microwave.
  • Call a_fancy_microwave's cook_baked_potato() method.

Warning: Do not try to eat baked potatoes after they have been cooked for 3 seconds as they will taste awful and you may suffer food poisoning.