Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions