Inheritance
Deitel 9-10
Part A
Think through common characteristics of animals, and write a class ZooAnimal.
Give ZooAnimal at least two instance variables of different types (protected)
representing information we would need to know about any animal. (hint:
type of animal would be a terrible choice -- which class we use will
take care of that)
Give ZooAnimal at least two methods representing behaviors -- things
that all
animals do, and most do the same way. These can simply print out a
message stating what the animal is doing.
Include at least one parameterized constructor.
Part B
Create classes Elephant and Camel both of which extend ZooAnimal.
In each,
include a default constructor that calls the parameterized superclass
constructor, passing it appropriate value(s).
To one class (of Elephant and Camel), add another instance variable, specific to that type of animal.
To one, add another behavior specific to that type of animal.
In one, override a behavior from ZooAnimal so that it happens in a way specific to this animal.
In each subclass, override toString, using super. to call the one from ZooAnimal inside it
and then add extra text specific to the class (including any new instance vars)