Session Ready
Exercise

Specifying a Fancy Microwave Oven

Inheritance is used to propagate – that is, copy – functionality from one class to another. To create a child class from another class, use the inherit argument to R6Class().

The pattern to create a child class is:

child_class_factory <- R6Class(
  "ChildClass",
  inherit = parent_class_factory
)
Instructions
100 XP

A microwave oven class has been defined for you in the variable microwave_oven_factory.

  • Create a FancyMicrowaveOven class that inherits from MicrowaveOven.
    • Call R6Class().
    • The classname argument should be "FancyMicrowaveOven".
    • The inherit argument should be microwave_oven_factory.
    • Assign this to the variable fancy_microwave_oven_factory. Do not add any extra functionality yet.