Define the class HotelRoom. The class has thefollowing private data members: the room number(an integer) and daily rate (a double). Include adefault constructor as well as a constructor with two parameters toinitialize the room number and the room’s daily rate. The classshould have get/set functions for all its private data members[20pts]. The constructors and the get/set functions must throw aninvalid_argument exception if either one of theparameter values are negative. The exception handler should displaythe message “Negative Parameter” [20pts]. Include atoString() function that nicely formats andreturns a string that displays the information about the hotel room[10pts].
- Write a main function to test the classHotelRoom, create a HotelRoomobject. Try to set the room rate to an invalid value to generate anexception. Invoke the toSting() function todisplay the HotelRoom object. [20pts]
- Derive the classes GuestRoom form the baseclass HotelRoom. The GuestRoomhas private data fields and public functions:
- The private data field capacity (an Integer)that represents the maximum number of guests that can occupy theroom. [5pts]
- The private data member status (an integer),which represents the number of guests in the room (0 ifunoccupied). [5pts]
- An integer data field days that represents thenumber of days the guests occupies the room. [5pts]
- Add constructors and get/set functions to theGuestRoom class. The set function for thestatus data member must throw anout_of_range exception if it tries to set statusto value greater than the capacity. [30pts]
- The function calculateBill() that returns theamount of guest’s bill. [10pts]
- Redefine the functiontoString() that formats and returns a stringcontaining all pertinent information about theGuestRoom. [15pts]
- Derive the classes MeetingRoom form the baseclass HotelRoom. The class has the followingprivate data filed sand public functions:
- A private data field seats, which representsthe number of seats in the room. [5pts]
- An integer data field status (1 if the room isbooked and 0 otherwise). [5pts]
- Add constructors and get/set functions to theGuestRoom class. [10pts]
- Redefine the functiontoSting() to format and return a string containingall pertinent information about the MeetingRoom. [20pts]
- The function CalculateBill(), which returnsthe amount of the bill for renting the room for one day. Thefunction calculates the bill as follows: the number of seatsmultiplied by 10.00, plus 500.00. [20pts]
- Write a main function to test the classesGuestRoom and MeetingRoom. Invokethe calculateBills and toStirng()in each of the objects. [40pts]]
- Make changes to the HotelRoom class toimplement polymorphism. Add avirtual function calculateBill()that returns 0.00 and make the toString() functionin the HotelRoom class a virtual function. Write the functiondisplayHotelRoom() that receive a base class typereference as a parameter, then invokes the functionscalculateBill() and toString().The function must return void. [50pts]
-
From the main function invoke the functiondisplayHotelRoom() three separate times and eachtime send a HotelRoom, aGuestRoom, and a MeetingRoom typeobjects. [20pts]
- Repeat parts e and f but make appropriate changes in such a waythat HotelRoom is turned into an abstract baseclass. [50pts]
Expert Answer
Answer to Define the class HotelRoom. The class has the following private data members: the room number (an integer) and daily rat…