Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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