Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this exercise, you are going to create a part of an Animal hierarchy. Unlike some of our examples and the previous exercises, this

 public class Animalpublic class Fish extends Petpublic class Pet extends Animalpublic class Dog extends Pet  
 
 

For this exercise, you are going to create a part of an Animal hierarchy. Unlike some of our examples and the previous exercises, this exercise is going to have 3 levels in the hierachry. At the top is the Animal class. Below that, we are going to have a subclass for Pets. Under pets, we are going to have 2 subclasses, Dogs and Fish. You will need to create your class hierarchy and add instance variables, getters, and setter methods to accommodate the following information: I need to save what type of animal I have (String variable) I want to be able to save a name for my fish and dog (String variable) I want to know which fish need salt water v. fresh water (String variable) I want to know if my dog has been trained (boolean variable) I want to know the size of my dog and fish (String variable) Make sure you use common sense names for your variables! public class Animal { } public class Fish extends Pet { } public class Pet extends Animal { } public class Dog extends Pet { }

Step by Step Solution

3.46 Rating (178 Votes )

There are 3 Steps involved in it

Step: 1

Below is the code package inheritance Defines a class Animal class Animal Instance variable to store animal type String animalType Parameterized const... 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

Data Analysis And Decision Making

Authors: Christian Albright, Wayne Winston, Christopher Zappe

4th Edition

538476125, 978-0538476126

More Books

Students also viewed these Computer Engineering questions

Question

What is the output of the following:x = x + 3 print ( x )

Answered: 1 week ago