Question: Create a Java Class named Pet. This class should contain private member variables for the name, age, species and weight as well as public methods

Create a Java Class named Pet. This class should contain private member variables for the name, age, species and weight as well as public methods to access and change the values of these variables. The class should also contain a method called display(), this method should display the status of the pet. The driver (main method) for this class should create at least 3 Pet objects, populate their data members and then call the display method for each pet. Class Pet -name: String -species: String -age: int -weight: double +setName(String) +getName(): String +setSpecies(String) +getSpecies(): String +setAge(int) +getAge(): int +setWeight(double) +getWeight(): double +display()

Example of program execution: (the bold faced text shows the variable values) You have the following pets: A 10 year old Cat named Jerry Mouse that weighs 12.5 pounds. A 3 year old Dog named Spot that weighs 29.0 pounds. A 2 year old Guinea Pig named Hork that weighs 1.1 pounds.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!