Question: Assignment Rules: Every variable within a class shall be private and non - static. This includes inherited variables. Every variable within a class shall have
Assignment Rules:
Every variable within a class shall be private and nonstatic. This includes inherited variables.
Every variable within a class shall have a Method to set the variable and a Method to return the variable.
All methods shall be nonstatic and public.
Each class shall contain a constructor method that sets every variable of the class.
You may optionally have other constructors with or more parameters, but they are not required.Example: If an Animal has a weight, age and height then you should have a constructor similar to: public Animalint inputWeight, int inputAge, int inputHeight
You shall have a separate test file that instantiates these Objects inside a main method with default values of your choosing and outputs them using System.out.println.
Now for the class descriptions. Some of these variables and methods are already done as a part of the lecture and you do not have to recreate these. Instead identify what is new and add it in I recommend starting with the Animal class then slowly moving through the rest of each class one at a time. Once you finish a new class test it out in your main method before moving on to the next one. Take this one step at a time and test often.
Class Descriptions:
The Animal is our base class
It has three attributes: a weight whole number integer in pounds an age whole number integer in years a heightwhole number integer in inchesIt has a toString method that outputs that it is an Animal and what its weight, height and age are
The Dog is a type of Animal
It has two additional attributes: a name String and a breed StringIt has a toString method that outputs the dog's name, breed, age, weight, and height
The Cat is a type of Animal
It has two additional attributes: a name String and a number of lives whole number integer, starts at It has a toString method that outputs the cat's name, age, weight, height, and how many lives it has remaining
The Bird is a type of Animal
It has three additional attributes: a wingspan real number, double in inches a species name string and whether it can fly or not booleanIt has a toString method that outputs the bird's species, wingspan, age, weight, height and whether it can fly
You should then have a test file with a main method that creates a Dog object, a Cat object and a Bird object. The test file outputs the data for each Object with a call to System.out.println and using the Object's toString method. The data input for each Object is up to you, but make it nonzero data. It does NOT have to be read in from the user via Scanner, but can be static numbers.
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
