Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need part c and D answered for my Java class Write code for a Pet class. Part

ID: 3844680 • Letter: I

Question

I need part c and D answered for my Java class Write code for a Pet class. Part of this is shown (including the getAge method). Fill in other blanks. int getAge() { return age }//methods for the Pet class that you will need//to fill in go here... a) Write a constructor method for the Pet class, to set the default name to "Fido", the default breed to "spider", the default age to 1, and the default weight to 0.5. Show the method header clearly. b) Fill in the set() method for the Pet class, with the given header: set name to newName. to, age to newAge, weight to newWeight. You must check that newAge is > =0, and weight > = 0.5. If either newAge or newWeight is not in the correct range, print an error message and return immediately, without changing any of the member variables of the Pet object. void net (String newName, String new, int newAge, float newWeight) { } 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

Explanation / Answer

c)

public class Yun {

   public static void main(String[] args) {

//Creating an Pet class Obejct
       Pet myFavPet = new Pet();

//Setting the Pet attribute values by calling the set Method
       myFavPet.set("Lassie", "Snake", 3, 45.6f);

   }

}

__________________

d)

   Pet olderPet(Pet onePet,Pet otherPet)
   {
       if(onePet.age>otherPet.age)
           return onePet;
       else if(otherPet.age>onePet.age)
           return otherPet;
       else
           return onePet;
      
   }


_____________Could you rate me well.Plz .Thank You