Question: The primary objective is to explore inheritance, interfaces, and their integration while managing pets treated and boarded at an animal hospital. Class: Pet The class

The primary objective is to explore inheritance, interfaces, and their integration while managing pets treated and boarded at an animal hospital.
Class: Pet
The class should have the three private data members: petName(String),ownerName(String), and color(String) along with one protected data member gender(int) representing male(0) or female(1).
Public methods:
Constructor: Pet(String petName, String ownerName, String color)
String getPetName()
String getOwnerName()
String getColor()
void setGender(int genderid)
String getGender(): Return the string equivalent of the gender, e.g Male
String toString(): Return the name, owners name, age, color, and gender
A Sample (preferred) return value by toString is as follows:
Spot owned by Mary.
Color: Black and White
Gender: Male
Interface: Boardable
This interface should contain the following public methods:
void setBoardStart(int month, int day, int year);
void setBoardEnd(int month, int day, int year);
boolean boarding(int month, int day, int year);
Refer to the Cat and Dog classes for implementing details. Note: Month ranges from 1 to12, day ranges from 1 to31, and year is a four-digit number.
Class: Cat
This class extends the Pet class and implements the Boardable interface. It introduces a private data member, hairLength, and provides the following public methods:
Cat (String name, String ownerName, String color, String hairLength):
Constructor for Cat object, invoking the superclass constructor.
String getHairLength(): Retrieves the hair length of the cat.
String toString(): Returns a detailed description of the cat, including the values from the Pet parent class.
To implement the Boardable interface, define new data members are added to store boarding start and end dates. The setBoardStart and setBoardEnd methods are implemented to set values for these dates, and a boarding method is provided to determine if the given date falls within the boarding period, returning true if it does, including cases where the date matches the start or end date.
A Sample (preferred) return value by toString is as follows:
CAT:
Tom owned by Bob.
Color: black
Sex: spayed
Hair: short
Class: Dog
This class should extend the Pet class and implement the Boardable interface. The Dog class should include a private string data member size in addition to inherited members from Pet.
Public methods provided should include:
Dog (String name, String ownerName, String color, String size): Initialize size and calls super.
String getSize(): Returns the size
String toString() :Returns a String identifying the pet as Dog and providing a complete description, including values from the Pet parent class.
A Sample (preferred) return value by toString is as follows:
DOG:
Spot owned by Susan.
Color: white
Sex: spayed
Size: medium
Class: AnimalHospital
This class neither extends other classes nor implements interfaces. It utilizes existing classes.
Declare final const fields for:
HOSPITAL_NAME
MAX_CAPACITY: Maximum number of animals the hospital can accommodate.
DEFAULT_TREATMENT_COST: default cost for treatments.
ACCEPTED_ANIMAL_CATEGORIES: Categories of animals the hospital accepts.
Public methods to be provided include:
AnimalHospital(String inputFile): Constructor takes a filename and read records for animals (starting with CAT or DOG), and creates Dog or Cat objects. It invokes the setBoardSrart and setBoardEnd methods during object creation.
void printPetInfoByName(String name): Searches for pets with the given given name, and print their information using toString().
void printPetInfoByOwner(String name): Searches for pets owned by the given person and print their information using toString().
void printPetsBoarding(int month, int day, year): Searches for pets boarding at the specified time and print their information using toString()
void printHospitalInfo(): Displays hospital information.
Sample of input data file: pets.txt
PET
Spot
Mary
Black and White
Male
CAT
Spot
Bob
Black
Female
Short
DOG
Hipper
James
Dark Brown
Female
Large
END
Driver Program:
public static void main(String[] args)
{
AnimalHospital hospital = new AnimalHospital("pets.txt");
System.out.println("Animal Hospital Information:");
hospital. printHospitalInfo();
System.out.println("Pets Named Spot");
hospital.printPetInfoByName("Spot");
System.out.println("");
System.out.println("Pets Owned by James");
hospital.printPetInfoByOwner("James");
System.out.println("");
System.out.println("Pets Currently Boarded");
hospital.printPetsBoarding(1,14,2021);
}

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!