Question: Create a class iPet with instance variables animalType, name, and age, and a constructor with three parameters to initialize an object for these three

Create a class iPet with instance variables animalType, name, and age, and

Create a class iPet with instance variables animalType, name, and age, and a constructor with three parameters to initialize an object for these three instance variables as well as the toString() method. - animalType: String - name : String - age : int UML iPet +iPet(t : String, n : String, a : int ) +speak(): void // if lion "Roar"; if dog "Bark" +toString(): String Then write an iPetTest.java with main() to create the two iPet objects Leo and Ruff: Leo the lion 5 years old. // toString() Roar! Ruff the dog 2 years old. Bark! // if( animalType.equals("lion"))

Step by Step Solution

3.50 Rating (153 Votes )

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 Programming Questions!