Question
Develop an object oriented program in Java that will keep track of pets treated in an animal hospital. Detail class specifications (data members, methods and
Develop an object oriented program in Java that will keep track of pets treated in an animal hospital. Detail class specifications (data members, methods and access modifiers) are described below. Please note the following requirements:
1. Class: Pet
The class should have the following public data members - pet name (a String), owner name (a String), color (a String), and sex (an integer, but it will only hold one of the following four public static final int values: MALE, FEMALE, SPAYED and NEUTERED. You should define these four as static in your class).
Following are the public methods that this class should provide:
void setPetName();
String getPetName();
void setOwnerName();
String getOwnerName();
void setColor();
String getColor();
void setSex(int sexid);
String getSex(); // Should return the string equivalent of the gender, e.g the string male etc.
String printPetInfo(); // Should display the name, owners name, age, color, and gender (use getSex());
A Sample (preferred) of printPetInfo is as follows:
Spot owned by Mary
Color is Black and White
Sex is Male
2. Class: Cat
This class should extend the Pet class. In addition to the data members and methods inherited from Pet, the Cat class should have a private hairLength data member, which is a string.
Following are the public methods that this class should provide:
Cat (String name, String ownerName, String color, String hairLength); // Constructor
void setHairLength();
String getHairLength(); // returns the string hairLength
String printCatInfo() // Should display the pet as Cat and hair length and a complete description of the cat included in the Pet parent class
A Sample (preferred) of printCatInfo is as follows:
CAT:
Friskies owned by Bob
Color is black
Sex is spayed
Hair is short
3. Class: Dog
This class should extend the Pet class. In addition to the data members and methods inherited from Pet, the Dog class should have a private size data member, which is a string.
Following are the public methods that this class should provide:
Dog (String name, String ownerName, String color, String size); // Constructor
void setSize();
String getSize(); // returns the string size
String printDogInfo(); // Should display the pet as Dog and size and a complete description of the dog included in the Pet parent class
A Sample (preferred) of printDogInfo is as follows:
DOG:
Spot owned by Susan
Color: white
Sex: spayed
Size: medium
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started