Question
Instructions Animal Class Instructions Create two java files: Animal.java AnimalDemo.java Animal Class.java Your Animal class should contain 3 private data members and 6 public methods
| |
Instructions | |
Animal Class Instructions Create two java files:
Animal Class.java Your Animal class should contain 3 private data members and 6 public methods as follows... Data Members:
Methods:
The getters and setters should respectively return or update the name, and the toString() method should override Java's built in toString method (which every Java object has), and should display something like this: Name: Jimmy. Age: 3. Species: Squirrel. You should also have two constructors for the Animal so that it is possible to initialize a new Animal with default data values of "Unnamed", -1, and "Unknown". The other constructor should take the three values needed to initialize a new Animal object with all three data members. AnimalDemo.java The AnimalDemo.java will be a driver class that you will use to demo the Animal class. The driver should initialize two animal objects. One animal should be constructed with its name, age, and species. (You decide those.) The other animal should be constructed with the default values, and subsequently use the setter methods to give the animal a name, age, and species. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started