Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. Animal.java
  2. AnimalDemo.java

Animal Class.java

Your Animal class should contain 3 private data members and 6 public methods as follows...

Data Members:

  • name
  • age
  • species

Methods:

  • getName()
  • setName()
  • getAge()
  • setAge()
  • getSpecies()
  • toString()

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

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_2

Step: 3

blur-text-image_3

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

8-15 Explain how a cyberattack can be carried out.

Answered: 1 week ago

Question

Write a report on a universal motor. ( no more than 3 pages )

Answered: 1 week ago

Question

Describe the new structures for the HRM function. page 676

Answered: 1 week ago