Question: Can you help with me with this JAVA problem? Thank you! A composition relationship ( Has - A ) in which you create another class

Can you help with me with this JAVA problem? Thank you!
A composition relationship (Has-A) in which you create another class which is a member of your class
Create an Inheritance Hierarchy (Is-A Relationship) with at least 4 classes total and with 3 levels of inheritance
Include at least two additional member variables/instance variables (select the appropriate data types) for each derived class. Use any type you like.
Create appropriate constructor methods in each derived class, including a default constructor (0 argument) and the all-argument constructor.
Create necessary accessor and mutator methods (these are the get methods)- one for each member variable.
Override a base class method (showValues, for example) in each of the derived classes so that the values will be displayed of the object with the additional member variables.
Make the base class abstract (cannot be instantiated) by having an abstract method. The base class should still have the 5 member variables, and the derived classes should have at least 2 member variables.
Create a method inputValues(), to accept input from the user for the values to go into an object, utilizing the hierarchical structure, using super().
Create a method in each derived class that outputs something about the derived class variables. This method will override an abstract method in the base class. For example, in an Animal class inheritance hierarchy, a speak() method can be created and overridden, that would meow for a Cat type object, bark for a Dog type object, and chirp for a Bird type object. Or, you can create a behavior (method) that the Dog, Cat and Bird do such as play().
Given that you will have at least 3 derived classes, make 2 objects of each (6 total objects) in the main method of your driver class, i.e. MyClassApps main() method (the public area of the application that will use the public, or exposed members of each class). You can flatten out the hierarchy if you like to make 4 classes in 2 levels (i.e. the abstract base class and 3 derived classes).
Create an array of your base class objects, at least 6, and store the references of each object, through assignment. For example: Dog poodle = new Dog(...); Animal[0]=dog; // do this for all 6 elements 0-5
Create an interface (uses the implements keyword) with at least two methods which you will implement in any or all of your derived classes (subclasses). For example, the Dog can implement an interface called ITraining, for example. You must have two methods overridden, and demonstrate them in main() as well as the toString() method. You can do this, for example the class declaration does both inheritance and implementing an interface:
Dog extends Animal implements ITraining {}
Output Requirements: (Exercise all methods, constructors to show their results/output)
In main(), Generate a report of the objects in your array with columns for each of the values, and making one column the output (a String) of the polymorphic method overriding the base class abstract method. Format the columns with headers and a footer.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!