Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Animal class defines two functions getName () & getHeartRare (), as shown in the figure above. These function return the values of the private

image text in transcribed
The Animal class defines two functions getName () & getHeartRare (), as shown in the figure above. These function return the values of the private member variables name & heartRate, respectively. The Mammal class is child of Animal, and defines one function: getLifeSpan (). This function returns the value of the private member variable lifeSpan. The Zebra class is a child of Mammal and defines one function getHabitat (). This function returns the value of the private variable habitat. The Bear class is a child of Mammal and defines one function getAverageSize (). This function returns the value of the private variable averageSize. From the description, above, complete the following: In your development environment, create a new directory, called Quiz 2. Using function and class names exactly as given in the description and figures above, create Java classes to design and represent all the classes in this hierarchy. Place these class files Inside the Quiz 2 directory. Besides the files created for this test, there should be no other files of any type under the Quiz 2 directory. For each class, define two constructors: a default, no-argument constructor, and a constructor to assign values to all the member variables, including the variables defined in the class's parent, if any. Adding getter and setter methods, in addition to the ones in the figure, is entirely optional; however, you can only use constructors to assign values to class instance variables from your Driver.java program. Use variable types exactly as given in the figure. All class-level member variables must be defined as private.Again, all class-level variables are private. Points will be deducted if this requirement or any other stated requirement is not fulfilled. Create a Driver class, called 'Driver.java', that has a main() function to test the class above. Use a Scanner to read the user's response for the name, heartRate, lifeSpan, and habitat. Use this data to construct a Zebra object. Display the object variables values using the functions given in the classes. Compile and run the Driver. Make sure it displays the expected output

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions