Exercises
Our park is full of diversity, not just in the species of dinosaurs but also in the roles of our employees. To model this diversity, we will be incorporating the concept of inheritance into our applications:
- Not all dinosaurs are the same. Some are small, others big. Some are herbivores, others carnivores. Create at least three subclasses for different types of dinosaurs that inherit from the base
Dinosaur
class.If you need inspiration, you can create a
FlyingDinosaur
subclass and anAquaticDinosaur
subclass from theDinosaur
class, each with its unique properties. (This is not the most optimal way to model this, but don’t worry about that now.) - Just like our dinosaurs, our employees also have diverse roles. Some are park managers, while others are security officers or veterinarians. Create subclasses for these employee roles that inherit from the
Employee
base class. Come up with at least three subclasses. - Inheritance doesn’t just stop at properties...