Question: Pet Hotel System This lab work involves building a system for placing your beloved pet in a pet hotel, when you are going out of
Pet Hotel System
This lab work involves building a system for placing your beloved pet in a pet hotel, when you are going out of
town.
There should be an abstract Pet class, which will represent friends of users. It should have pet id int name,
owner and age as common attributes.
Following that, two classes will be inherited from Pet: Cat and Dog. Cat has one more attribute, which is Breed
Also, Dog class has an attribute of its own, which is Size
Size is a string that can be one of the following: XS
S
M
L and XL
Next, there is the Hotel class. This class is the platform that hold pets that users brought. It has two attributes:
name and a data structure of your choice to hold pets. Other than these, it should have three methods:
reservePet, leavePet and printHotelInfo for manipulating Pet objects.
reservePet method will store a Pet in the data structure. The hotel can only hold pets, at most. In addition, if
a dogs size exceeds M
the hotel cannot hold it If any of these conditions occur, this method should throw
SizeLimitExceededException
This will not stop the program, print proper error and continue the program.
leavePet takes a Pet Id as a parameter to find and remove that Pet from the data structure.
printHotelInfo prints the name of the hotel and its current residents with their informations as well.
In your main, create a Hotel object and six different pets. Then, print a menu where the user can see following:
Welcome to hotelName Pet Hotel:
Reserve Pet
Take your Pet
Exit
Your program should run until the user exits. Continuously reserve and take out pets to demonstrate your work.
Try reserving more than five pets or a dog that is larger than size M When the exception is thrown, find out
the reason and print proper error. If the reason is that, there is no more room in the hotel, print out the hotel
information to prove.write java code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
