Write the header file Hotel.h for a Hotel class. The Hotel class has the followi
ID: 3917569 • Letter: W
Question
Write the header file Hotel.h for a Hotel class. The Hotel class has the following data members: 1) an array of 100 Room objects. 2) hotel name and 3) the number of occupied rooms. The Room is represented as a struct in a room.h file. The Room structure has the following data members: 1) Room Number 2) Primary Guest Full Name and 3) Room Cost per Night. In addition, provide the following member function prototypes for the Hotel class: (in C++)
Hotel Constuctor: string hotelName parameter.
assignRoom(...): double roomNumber and string guestName parameters, returns nothing
unAssignRoom(...): integer roomNumber parameter, returns nothing
getNumberOfAssignedRooms() : no parameters and returns the number of assigned rooms.
getCostOfRoom(...): double roomNumber parameter and returns the cost of the room
Do not provide the implementation of the member functions.
#ifndef ROOM_H
#define ROOM_H
//Place code here for Room Struct
#endif
///////////////////////////////////////////////////
#ifndef HOTEL_H
#define HOTEL_H
//Place code here for Hotel Class
#endif
?
Explanation / Answer
room.h
//File for room structure
#ifndef ROOM_H
#define ROOM_H
#include<iostream>
using namespace std;
struct Room
{
int roomNumber;
string guestName;
float costPerNight;
};
#endif
Hotel.h
//File for hotel class
#ifndef HOTEL_H
#define HOTEL_H
//Include the Room structure header file
#include"room.h"
class Hotel
{
Room arr[100];
string hotelName;
int numOfOccupiedRooms;
public:
Hotel(string hotelName);
void assignRoom(double roomNumber, string guestName);
void unAssignRoom(int roomNumber);
int getNumberOfAssignedRooms();
float getCostOfRoom(double roomNumber);
};
#endif
Kindly give a thumbs up, if found useful. Comment for queries. :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.