Answered step by step
Verified Expert Solution
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
The room number
private int number;
The availability of the room, true if available
private boolean availability;
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 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.
tableStatementValue Returned,Class SpecificationtableHotelRoom newHotelRoom true; is room and available.tableHotelRoom newHotelRoom false;table is room and it is NOTavailabletableLuxurysuite newLuxurySuite Meal truetable is room and available. Itis a LuxurySuite withadditional "Meal" service withan extra cost of $tableLuxurySuite newLuxurySuite King Bed", falsetable is room and it is NOTavailable It is a LuxurySuitewith additional "King Bed"service with an extra cost of$rl getRoomStatus ; is available",tableA String indicating the roomnumber and availability of theHotelRoom is returned.r getRoomstatus; is not available",tableA String indicating the roomnumber and availability of theHotelRoom is returned.r getRoomStatus; is available with extra cost $tableA String indicating the roomnumber availability and extracost of the LuxurySuite isreturnedrgetRoomStatus ; is not available with extra cost $tableA String indicating the roomnumber availability and extracost of the LuxurySuite isreturnedr changeCost r;tableCannot change room from to because is not occupied.r changecost ;tableChanging a LuxurySuite to aregular available HotelRoomcosts half of the extra cost of theLuxurySuiter changeCost r;tableCannot change room from to because is occupied.r changeCost ;tableChanging a LuxurySuite toan available LuxurySuite isfree
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