Answered step by step
Verified Expert Solution
Link Copied!

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 1000 and maximum number of rooms is 350.
- 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 0, default number of rooms to 0 and the isAvailable flag to True. Print execuon trace: Block inializer.
- Constructor1 with 3 parameters: validates the number of guests and rooms to be in the range (0, max no of rooms) and the number of guests in the range (0, max no of guests). Use stac validaon funcons, raise errors. Print execuon trace Constructor 13 parameters.
- Provide Set methods for Number Rooms and Number Guests.
- Constructor 2 with one parameter isAvailable. Call Constructor 1 with the default values for the other two parameters (0 guests and 0 rooms). Print a trace Constructor21 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 3 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions