Inheritance


Inheritance

Monster.java
VampireBat.java
MuppetMonster.java
MonsterTestHarness.java
 Month.java

Pet.java
Cat.java
Dog.java
Budgie.java
PetHarness.java

Deitel chapter 9-10.


Classwork


A zoo is developing an educational safari game with various animals. You will write classes representing Elephants, Camels, and Moose.  

Part A

Think through common characteristics of animals, and write a class ZooAnimal.

ZooAnimal should have at least two instance variables of different types (protected), representing characteristics that all animals have values for. 

It should also have at least two methods for behaviors that all animals do; these can simply print out a String stating what the animal is doing. (accessors and mutators are not behaviors).

Include at least one parameterized constructor.

Part B

Create classes Elephant, Camel, and Moose, all of which extend ZooAnimal.  In each, include a default constructor that calls the parameterized superclass constructor.  

To one class (of Elephant, Camel, and Moose), add another instance variable specific to that type of animal. To another, add another behavior method. In a third, override a behavior from ZooAnimal.  

Part C

Create a test harness for the animal classes. In a main create at least one Elephant, Camel, and Moose, and show which behavior methods are usable for each.

☑ [EC] Create another animal class inheriting from one of your three types (doesn't have to be zoologically accurate, but should make some sense), and either add an instance variable or add or override a method. This class should also be tested in the harness.