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 HasA in which you create another class which is a member of your class
Create an Inheritance Hierarchy IsA Relationship with at least classes total and with levels of inheritance
Include at least two additional member variablesinstance 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 argument and the allargument 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 member variables, and the derived classes should have at least 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 derived classes, make objects of each total objects in the main method of your driver class, ie 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 classes in levels ie the abstract base class and derived classes
Create an array of your base class objects, at least and store the references of each object, through assignment. For example: Dog poodle new Dog; Animaldog; do this for all elements
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 resultsoutput
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
