Question: Create a class Hotel with the following elements: - Instance variables: int numberRooms, int numberGuests, boolean isAvailable : Seters for all - Maximum of guests
Create a class Hotel with the following elements:
Instance variables: int numberRooms, int numberGuests, boolean isAvailable : Seters for all
Maximum of guests allowed is and maximum number of rooms is
One stac inializer block to setup the constant values. Print execuon trace: Stac bloc inializer
One inializer block to set the default number of guests to default number of rooms to and the isAvailable flag to True. Print execuon trace: Block inializer
Constructor with parameters: validates the number of guests and rooms to be in the range max no of rooms and the number of guests in the range max no of guests Use stac validaon funcons raise errors. Print execuon trace Constructor parameters
Provide Set methods for Number Rooms and Number Guests.
Constructor with one parameter isAvailable. Call Constructor with the default values for the other two parameters guests and rooms Print a trace Constructor parameter
Override compareTo the hotel with more rooms is greater
Overrride toString: prints the class data
Override equals: the no of rooms and no of guests should be the same,
Class HotelReservaon
main :
create hotel instances, two with the first constructor, one with the second.
When run main, the trace messages should display.
Use the compareTo method to compare two of the above instances. Display the one that is bigger making use of the toString method.
Make the output user friendly.
Force a validaon error at the end
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
