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

Create a class called Pet which contains: - A field for the name of the pet - A

ID: 657356 • Letter: C

Question

 Create a class called Pet which contains:         - A field for the name of the pet         - A field for the age of the pet         - Appropriate constructor and accessors Create a class called Dog which extends the Pet class and has:         - A field for breed of dog         - A field for body weight         - Appropriate constructor and accessors         - A toString method that prints the name, age, breed and weight of the dog Create a class called Cat which extends the Pet class and has:         - A field that describes the coat of the cat (example: short/long/plush/silky/soft)         - A field for whether it is a lap cat         - Appropriate constructor and accessors         - A toString method that prints the name, age and coat type of the cat, and whether it is a lap cat Create a class called Fish which extends the Pet class and has:         - A field for type of fish         - A field for the color of its scales         - Appropriate constructor and accessors         - A toString method that prints the name, age, type and scale color of the fish  Write a main which asks the user to enter the number of pets (n) and then ask for the details of n pets.  For each pet, first ask the user for the type of pet, then ask for the correct information depending on the type and create a Dog,Cat or Fish object as required. Add each pet to an ArrayList of Pets. After all information is entered and stored, print out the gathered information of all objects in the list, starting with the all the Fish first, then Cats and then Dogs. 

Explanation / Answer

public class Pet{
String name;
int Petage;
String color;

public Pet(String name){
// This constructor has one parameter, name.
}

}
public setAge( int age ){
PetAge = age;
}

public getAge( ){
System.out.println("Pet's age is :" + PetAge );
return puppyAge;
}
}
  
public interface Pet
{
public void setAge(int age);

}
  
public static void main(String []args){
/* Object creation */
Pet myPet = new Pet( "tommy" );

  
myPet.setAge( 2 );


myPet.getAge( );


System.out.println("Variable Value :" + myPet.PetAge );
}
}
public interface Dog extends Pet
{
String breed;
double weight;
  
public setBreed( string breed ){
PetBreed = age;
}

public getBreed( ){
System.out.println("Pet's age is :" + PetBreed );
return PetBreed;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote