Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the class Hotel, as declared below, which keeps track of the reservation status of each room in a hotel. Each room can be RESERVED,

Implement the class Hotel, as declared below, which keeps track of the reservation status of each room in a hotel. Each room can be RESERVED, OCCUPIED, or EMPTY, and this information is stored in a 2-dimensional array, where each row represents a floor, and each column represents a room. Each room is represented by an integer (e.g., 425). For example, the status of room 425 is stored in m_rooms[4][25].

const char RESERVED = 'R';

const char OCCUPIED = 'O';

const char EMPTY = 'E';

const int FLOORS = 20;

const int ROOMSPERFLOOR = 50;

class Hotel { public: Hotel(); bool reserve(int roomNum); bool cancel(int roomNum); bool checkIn(int roomNum); bool checkOut(int roomNum); int numEmpty(int floor) const; private: char m_rooms[FLOORS][ROOMSPERFLOOR]; // More private members here, if necessary. }; Hotel::Hotel() { // EMPTY the rooms. for (int i = 0; i < FLOORS; i++) for (int j = 0; j < ROOMSPERFLOOR; j++) m_rooms[i][j] = EMPTY; } Implement other functions below. bool Hotel::reserve(int roomNum) { // TODO: If the room is EMPTY, set it to RESERVED, and return true. // In all other cases, do not change anything and return false. }

bool Hotel::cancel(int roomNum) { // TODO: If the room is RESERVED, set it to EMPTY, and return true. // In all other cases, do not change anything and return false. } bool Hotel::checkIn(int roomNum) { // TODO: If the room is RESERVED, set it to OCCUPIED, and return true. // In all other cases, do not change anything and return false. } bool Hotel::checkOut(int roomNum) { // TODO: If the room is OCCUPIED, set it to EMPTY, and return true. // In all other cases, do not change anything and return false. } int Hotel::numEmpty(int floor) { // TODO: Return the number of empty rooms on the floor. // Return -1 if floor is invalid. } // Write helper functions down here if necessary.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions