Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There are several types of rooms in a hotel. The HotelRoom class of previous Pro

ID: 3670924 • Letter: T

Question

There are several types of rooms in a hotel. The HotelRoom class of previous Programming Problems was not specific regarding the type of room. Assume that a hotek has guest rooms and meeting rooms. Modify the HotelRoom class as follows: remove the capacity and status instance variables and associated methods. Change the class 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 guest 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 instance 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 otherwise). Code all appropriate constructors, copy constructors, and destructors for the classes. Code a function main () to test the classes. Make sure to create objects of all types in C++.

// page588.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class HotelRoom
{
public:
   int roomNumber;
   string roomType;
   int rent;
   int capacity;

};
int main()
{;
   class HotelRoom Hotel= Hotel; 200;
   int count=0;
   int i=0;
   while(true)
   {

       cout<<" Enter Room Number : ";
       cin>>Hotel.roomNumber;
       cout<<"Enter Room Type : ";
           cout<<"Enter Per night Rent : ";
           cin>>Hotel.rent;
           cout<<"Enter maximum people allowed : ";
           cin>>Hotel.capacity;
           count++;
           cout<<"Do you want to enter more room information , if yes than type Y else N ";
           char choice;
           cin>>choice;
           if(choice!='y' && choice!='Y')
           {
               break;
   }
   for(int i=0;i<count;i++)
   {
       cout<<" Room "<<(i+1)<< ": ";
       cout<<" RoomNumber : "<<Hotel.roomNumber;
       cout<<" RoomType : "; Hotel.roomType;
       cout<<" RoomRent : $ "<<Hotel.rent;
       cout<<" RoomCapacity : "<<Hotel.capacity<< "people ";
   }
   return 0;
}


}
  

Explanation / Answer

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class HotelRoom
{
public:
int roomNumber;
string roomType;
int rent;
   HotelRoom()
   {
   roomNumber=0;
   roomType="N/A";
   rent=0;
   }
   HotelRoom(int roomNumber,string roomType,int rent)
   {
   this.roomNumber=roomNumber;
   this.roomType=roomType;
   this.rent=rent;
   }
};


class GuestRoom:public HotelRoom
{
int capacity,status,noDays;
GuestRoom(int roomNumber,string roomType, int rent, int capacity,int status, int noDays) : HotelRoom(int roomNumber,string roomType,int rent)
{
   this.capacity=capacity;
   this.status=status;
   this.noDays=noDays;
}
}

class MeetingRoom:public HotelRoom
{
int seats,seatStatus;
GuestRoom(int roomNumber,string roomType, int rent, int seats,int seatStatus) : HotelRoom(int roomNumber,string roomType,int rent)
{
   this.status=status;
   this.seatStatus=seatStatus;
}
}


int main()
{
   GuestRoom gs=new GuestRoom(__,"",__,__,__,__,__); //specify your values
   MeetingRoom mr=new MeetingRoom(__,"",__,__,__,__); //specify your values
int count=0;
int i=0;

//Prepare Menu as per your wishes :)
return 0;
}

}