Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The HotelRoom class is used to store information about a hotel room. A partial HotelRoom class definition is shown. public class HotelRoom l * *

The HotelRoom class is used to store information about a hotel room. A partial HotelRoom class definition is shown.
public class HotelRoom
l**** The room number **?
private int number;
1**** The availability of the room, true if available */
private boolean availability;
1**** Creates a new HotelRoom with given parameters */
public HotelRoom (int number, boolean isAvailable)
??**** Returns the availability of the HotelRoom implementation not shown */
??**** Returns a String containing the room number and availability implementation not shown */
// There may be instance variables, constructors, and methods that are not shown.
You will write a class LuxurySuite, which is a subclass of HotelRoom. A LuxurySuite provides services, which is a String containing descriptions of all the additional services, and an extraCost, which is a positive double used to indicate the extra cost of the additional services.
The getRoomstatus method, when called on by a LuxurySuite, returns a String that also includes the extra cost, as shown in the example on the next page.
Information about the room number and availability must be maintained in the HotelRoom class.
The LuxurySuite class contains an additional method, changeCost, which returns a double indicating the cost of changing from a currently occupied / unavailable Luxurysuite to another available HotelRoom indicated by the parameter. In any other cases, the rooms are not changeable, the method would return 0.0. The cost of changing a LuxurySuite to a regular Hotel Room is half of the extra cost of a LuxurySuite, whereas changing a LuxurySuite to another LuxurySuite is free.
The following table contains a sample code execution sequence and the corresponding results. The code execution sequence appears in a class other than HotelRoom or LuxurySuite.
\table[[Statement,Value Returned,Class Specification],[\table[[HotelRoom r1= new],[HotelRoom(101, true);]],,r1 is room 101 and available.],[\table[[HotelRoom r2= new],[HotelRoom(201, false);]],,\table[[r2 is room 201 and it is NOT],[available.]]],[\table[[Luxurysuite r3= new],[LuxurySuite ("Meal",],[50.0,301, true)]],,\table[[r3 is room 301 and available. It],[is a LuxurySuite with],[additional "Meal" service with],[an extra cost of $50.0.]]],[\table[[LuxurySuite r4= new],[LuxurySuite ("King Bed",],[20.0,401, false)]],,\table[[r4 is room 401 and it is NOT],[available. It is a LuxurySuite],[with additional "King Bed"],[service with an extra cost of],[$20.0.]]],[rl. getRoomStatus ();,"101 is available",\table[[A String indicating the room],[number and availability of the],[HotelRoom is returned.]]],[r2. getRoomstatus();,"201 is not available",\table[[A String indicating the room],[number and availability of the],[HotelRoom is returned.]]],[r3. getRoomStatus();,"301 is available with extra cost $50.0",\table[[A String indicating the room],[number, availability and extra],[cost of the LuxurySuite is],[returned.]]],[r4.getRoomStatus ();,"401 is not available with extra cost $20.0",\table[[A String indicating the room],[number, availability and extra],[cost of the LuxurySuite is],[returned.]]],[r3. changeCost (r1);,0.0,\table[[Cannot change room from r3 to],[r1 because r3 is not occupied.]]],[r4. changecost (x1;,10.0,\table[[Changing a LuxurySuite to a],[regular available HotelRoom],[costs half of the extra cost of the],[LuxurySuite.]]],[r4. changeCost (r2);,0.0,\table[[Cannot change room from r4 to],[r2 because r2 is occupied.]]],[r4. changeCost (r3);,0.0,\table[[Changing a LuxurySuite to],[an available LuxurySuite is],[free.]]]]
image text in transcribed

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

More Books

Students also viewed these Databases questions

Question

1. What is meant by Latitudes? 2. What is cartography ?

Answered: 1 week ago