We will use the Animal
base class to generalize the requirements for animals. First, we will specialize the base class in two subclasses: Dog
and Frog
. Then, we will create a Party
class that will be able to work with instances of any Animal
subclass through duck typing. We will work with a party of dogs and a party of frogs.
Then, we will create a HorseDeeJay
class and generate a subclass of the Party
class named PartyWithDeeJay
. The new subclass will work with instances of any Animal
subclass and any instance that provides the properties and methods declared in the HorseDeeJay
class through duck typing. We will work with the party of dogs with a DJ.