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

three subclasses representing the three different types of animals taken in by o

ID: 3704853 • Letter: T

Question

three subclasses representing the three different types of animals taken in by our shelter: cats, dogs, and reptiles. For each animal, we will note the animal's name, general description, approximate age and the arrival and adoption dates. Each animal should also have a unique shelter id which is assigned when a pet is turned over to the shelter. For Cats and Dogs, we will also record the animal's bred and sex. The type of reptile (snake, turtle, lizard, etc) should be noted for Reptiles.

can you just write the cat class useing jgrasp?

Explanation / Answer

class AnimalShelter // base class
{
private String name,description;
private int age;
private String arrivalDate , adoptionDate;
int shelterId ;

public AnimalShelter(int shelterId,String name,String description,int age,String arrivalDate,String adoptionDate)
{
  this.shelterId = shelterId;
  this.name = name;
  this.description = description;
  this.age = age;
  this.arrivalDate = arrivalDate;
  this.adoptionDate = adoptionDate;
  
}
public int getShelterID()
{
  return shelterId;
}
public String getName()
{
  return name;
}
public String getDescription()
{
  return description;
}
public int getAge()
{
  return age;
}
public String getArrivalDate()
{
  return arrivalDate;
}
public String getAdoptionDate()
{
  return adoptionDate;
}
}
class Cat extends AnimalShelter
{
private String breed, sex;

public Cat(int shelterId,String name,String description,int age,String arrivalDate,String adoptionDate,String breed,String sex)
{
super(shelterId,name,description,age,arrivalDate,adoptionDate);// passing arguments to base class constructor
this.breed = breed;
this.sex = sex;
}
public String toString()
{
return " Shelter ID : "+getShelterID()+ " Name : "+getName()+ "Description : "+getDescription()+ " Age : "+ getAge()
+" Arrival date : "+getArrivalDate()+" Adoption date : "+getAdoptionDate();
}
}

class Dog extends AnimalShelter
{
private String breed, sex;
public Dog(int shelterId,String name,String description,int age,String arrivalDate,String adoptionDate,String breed,String sex)
{
super(shelterId,name,description,age,arrivalDate,adoptionDate);
this.breed = breed;
this.sex = sex;
}


}
class Reptile extends AnimalShelter
{
private String type;
public Reptile(int shelterId,String name,String description,int age,String arrivalDate,String adoptionDate,String type)
{
super(shelterId,name,description,age,arrivalDate,adoptionDate);
this.type = type;
}

}
class TestShelterAnimals
{
public static void main (String[] args)
{
Cat c = new Cat(10,"kitty","black colored",3,"04/29/2003","10/06/2003","American Curl","female") ;

System.out.println(c);
}
}

Output:

Shelter ID : 10 Name : kittyDescription : black colored Age : 3 Arrival date : 04/29/2003 Adoption date : 10/06/2003

Do ask if any doubt. Please upvote.