Question: You will create a series of simple classes which make up a class hierarchy for a few species of birds and mammals. Classes you create
You will create a series of simple classes which make up a class hierarchy for a few species of birds and mammals. Classes you create should include: AnimalKingdom, Chordata, Bird, Mammal, and Robin and Emu representing two different species of Bird, and Human and Kangaroo representing two different species of mammals. Think about how sub-classes inherit methods from super-classes.
Write the MainKingdom Class with a main method that instantiates at least one Kangaroo, Robin, Emu, and Human and demonstrates your implementation of these classes - calling all the available methods for each. Feel free to create additional methods in the MainKingdom class (or other classes) to do all these calls if that makes this easier.
package animalkingdom; public class Mammal { private String name; public Mammal(String name) { this.name = name; } public void drinkMilk() { System.out.println(this.name + " is drinking milk"); } public String getName() { return name; } } Every animal kingdom class should be supported with : public String toString() returns the object name along with a list of where it is in the classification of living organisms. For instance, the method on an object named Jesse of the class Dog, should return something like Jesse (Dog, Mammal, Chordata, Animal Kingdom)
I need help creating the toString method within the Mammal class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
