Assume that a hotel has guest rooms and meeting rooms. Modify the HotelRoom clas
ID: 3558108 • Letter: A
Question
Assume that a hotel has guest rooms and meeting rooms. Modify the HotelRoom class as fol- lows: remove the capacity and status instance variables and associated meth- ods. Change the classs constructor, copy constructor, and destructor accordingly. Derive from HotelRoom the classes GuestRoom and MeetingRoom. GuestRoom contains the following data members: the integer instance variable capacity, which represents the maximum number of guests that can occupy the room; the integer instance variable status, which represents the number of guests in the room (0 if unoccupied); and the integer instance variable days, which represents the number of days the guest occupies the room.MeetingRoom has the integer in- stance variable seats,which represents the number of seats in the room,and the integer instance variable status (1 if the room is booked for a meeting; 0 other- wise). Code all appropriate constructors, copy constructors, and destructors for the classes. Code a function main() to test the classes. Make sure to create ob jects of all types. Here is the previous code I have to work with:
#include<iostream>
#include<string>
using namespace std;
//class declatration
class HotelRoom
{
private: string roomNumber;
int capacity;
int occupancy;
double rate;
public:
//constructor with three parameters
HotelRoom(string num, int count, double rent)
{
roomNumber = num;
capacity = count;
rate = rent;
occupancy = 0;
}
};
int main()
{
//create instance of class
HotelRoom room1("F103", 2, 800);
//pause system for a while
system("pause");
return 0;
}
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
class HotelRoom
{
private:
int _roomNumber;
int _roomCapacity;
int _occupancyStatus;
double _dailyRate;
public:
HotelRoom();
void setRoomNumber(int roomNum);
int getRoomNumber();
int setRoomCapacity(int roomCap);
int getRoomCapacity();
int setoccupancyStatus(int occupStatus);
int getoccupancyStatus();
double setdailyRate(double dRate);
double getdailyRate();
void initRoom(int roomNum,int roomCap, double roomRate, int occupStatus);
int ChangeStatus(int occupStatus);
double ChangeRate(double roomRate);
};
void HotelRoom::setRoomNumber(int roomNum)
{
_roomNumber = roomNum;
}
int HotelRoom::getRoomNumber()
{
return _roomNumber;
}
int HotelRoom::setRoomCapacity(int roomCap)
{
_roomCapacity = roomCap;
return _roomCapacity;
}
int HotelRoom::getRoomCapacity()
{
return _roomCapacity;
}
int HotelRoom::setoccupancyStatus(int occupStatus)
{
_occupancyStatus = occupStatus;
return _occupancyStatus;
}
int HotelRoom::getoccupancyStatus()
{
return _occupancyStatus;
}
double HotelRoom::setdailyRate(double dRate)
{
_dailyRate = dRate;
return _dailyRate;
}
double HotelRoom::getdailyRate()
{
return _dailyRate;
}
int main()
{
HotelRoom* _HotelRoom;
int roomNum;
roomNum = 123;
int roomCap;
roomCap = 4;
double roomRate;
roomRate = 150.00;
_HotelRoom->setoccupancyStatus(0);
_HotelRoom->setRoomCapacity(5);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.