Question: 4) Write code for a Pet class. Part of this is shown (including the getAge method). Fill in other blanks.20 points class Pet { //

 4) Write code for a Pet class. Part of this is
4) Write code for a Pet class. Part of this is shown (including the getAge method). Fill in other blanks.20 points
class Pet {
// name of pet
private String name;
private String breed;
// type of pet (dog, cat,
private int age;
// etc)
in years
// age of pet
private float weight;
// must be >=
0
// min weight
0.5
// must be >=
int getAge() { return age;
}
// methods for the Pet class that you will need
// to fill in go here...
}

c) In the public class below, write Java statements to declare an object called myFavPet of the class Pet, and set the name of myFavPet to Lassie". breed to "snake", age to 3 weight to 45.6. public class Yum public static void main (String args) objects, and returns the one which is older (i.e., has the larger age). If the age are identical, it returns the first Pet object (onePet). Pet older Pet (Pet one Pet, Pet other Pet)

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!