LAB EXERCISE 1 PART 2 Based on the given codes forr Hotelh and maincpp create Hotelcpp so that

LAB EXERCISE 1 (PART 2) Based on the given codes for Hotel.h and main.cpp, create Hotel.cpp so that the output will be as shown below: Room Bookings: Room 0 booked by Alice for 3 nights Room 1 booked by Bob for 2 nights Room 3 booked by Carol for 4 nights Room Bookings: Room 0 booked by Alice for 3 nights Room 3 booked by Carol for 4 nights ...Program finished with exit code 0 Press ENTER to exit console. Hotel.h #ifndef HOTEL_H #define HOTEL_H #include #include class Reservation { public: Reservation(int roomNumber, const std::string& guestName, int nights); int getRoomNumber() const; const std::string& getGuestName() const; int getNights() const; private: int roomNumber; std::string guestName; int nights; }; class Hotel { public: Hotel(int numRooms); Hotel(); bool bookRoom(int roomNumber, const std::string& guestName, int nights); bool cancelBooking(int roomNumber); void displayBookings() const; private: int numRooms; std::vector reservations; bool* roomAvailability; }; #endif Main.cpp #include "Hotel.h" #include int main() { Hotel hotel(10); // Creating a hotel with 10 rooms hotel.bookRoom(0, "Alice", 3); hotel.bookRoom(1, "Bob", 2); hotel.bookRoom(3, "Carol", 4); hotel.displayBookings(); hotel.cancelBooking(1); hotel.displayBookings(); return 0; }

LAB EXERCISE 1 (PART 2)

Based on the given codes for Hotel.h and main.cpp, create Hotel.cpp so that the output will be as shown below:

Room Bookings:
Room 0 booked by Alice for 3 nights
Room 1 booked by Bob for 2 nights
Room 3 booked by Carol for 4 nights

Room Bookings:
Room 0 booked by Alice for 3 nights
Room 3 booked by Carol for 4 nights

…Program finished with exit code 0
Press ENTER to exit console.

Hotel.h

#ifndef HOTEL_H
#define HOTEL_H

#include
#include

class Reservation
{
public:
Reservation(int roomNumber, const std::string& guestName, int nights);
int getRoomNumber() const;
const std::string& getGuestName() const;
int getNights() const;

private:
int roomNumber;
std::string guestName;
int nights;
};

class Hotel
{
public:
Hotel(int numRooms);
Hotel();
bool bookRoom(int roomNumber, const std::string& guestName, int nights);
bool cancelBooking(int roomNumber);
void displayBookings() const;

private:
int numRooms;
std::vector reservations;
bool* roomAvailability;
};

#endif

Main.cpp

#include “Hotel.h”
#include

int main()
{
Hotel hotel(10); // Creating a hotel with 10 rooms
hotel.bookRoom(0, “Alice”, 3);
hotel.bookRoom(1, “Bob”, 2);
hotel.bookRoom(3, “Carol”, 4);
hotel.displayBookings();
hotel.cancelBooking(1);
hotel.displayBookings();

return 0;
}


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (4 ratings) 4 out of 4 people found this solution helpful.