Hotel Management System: Project For Opps
Hotel Management System: Project For Opps
Hotel
Management
System
Submitted to Sarabjit sir
Aanshi
Bhavya
▪ This example of a hotel management system in C++ demonstrates how object-oriented programming
principles can be used to manage complex tasks. By encapsulating room properties and behaviors within the
`Room` class and managing these rooms within the `Hotel` class, the code achieves a modular and
maintainable structure. Key operations like checking in and out guests, and displaying room statuses, are
implemented as methods, making the system easy to understand and extend.
▪ 1. **Object-Oriented Design:** Using classes to represent entities like `Room` and `Hotel` encapsulates data
and behavior, enhancing code organization and readability.
▪ 2. **Data Management:** The use of a vector to store `Room` objects allows dynamic management of room
information.
▪ 3. **User Interaction:** A simple menu-driven interface facilitates interaction, demonstrating basic input
handling and control structures in C++.
▪ 4. **Scalability:** The design can be easily expanded to include more features, such as handling
reservations, managing different room types, and integrating a billing system.
▪ This basic implementation provides a solid foundation for a more comprehensive hotel management system,
showcasing how fundamental programming concepts can be applied to solve real-world problems effectively.
▪ ```cpp
▪ class Room {
▪ public:
▪ };
▪ ```
▪ - **Members:**
▪ - `guestName`: A string storing the name of the guest if the room is occupied.
▪ - **Constructor:**
▪ ```cpp
▪ class Hotel {
▪ private:
▪ std::vector<Room> rooms; //
▪ public:
▪ Hotel(int numberOfRooms) {
▪ rooms.emplace_back(i);
▪ }
▪ }
▪ return;
▪ }
▪ if (room.isOccupied) {
▪ } else {
▪ room.isOccupied = true;
▪ Room.guestName = guestName;
▪ }
▪ }
▪
▪ if (roomNumber <= 0 || roomNumber > rooms.size()) {std::cout << “Invalid room number.\n”;
▪ return;
▪ }
▪ if (!room.isOccupied) {
▪ } else {
▪ std::cout << “Guest “ << room.guestName << “ checked out from room “ << roomNumber << “.\n”;
▪ room.isOccupied = false;
▪ room.guestName = “”;
▪ }
▪ }
▪ void displayStatus() {
▪ }
▪ }
▪ };
▪ ```
▪ - **Members:**
▪ - **Constructor:**
▪ - Initializes the hotel w ith a specified number of rooms by creating `Room` objects w ith room numbers from 1 to `numberOfRooms `.
▪ - **Methods:**
▪ - `checkIn(int roomNumber, const std::string& guestName)`: Checks a guest into a specified room if the room is not already occ upied. If the room is occupied or
the room number is invalid, it prints an error message.
▪ - `checkOut(int roomNumber)`: Checks a guest out of a specified room if the room is occupied. If the room is vacant or the room number is invalid, it prints an
error message.
▪ - `displayStatus()`: Displays the occupancy status of all rooms, show ing either the guest name for occupied rooms or “Vacant” for empty rooms.
▪ The `main` f unction prov ides the user interf ace to interact with the hotel management sy stem.
▪ ```cpp
▪ int main() {
▪ Hotel hotel(numberOf Rooms); // Create a hotel with the specif ied number of rooms
▪ std::string guestName;
▪ While (true) {
▪ std::cout << “\n1. Check In\n2. Check Out\n3. Display Status\n4. Exit\nEnter your choice: “;
▪ switch (choice) {
▪ case 1:
▪ std::getline(std::cin, guestName);
▪ Hotel.checkIn(roomNumber, guestName);
▪ break;
▪ case 2:
▪ hotel.checkOut(roomNumber);
▪ break;
▪ case 3:
▪ hotel.display Status();
▪ break;
▪ case 4:
▪ return 0;
▪ Default:
▪ break;
▪ }
▪ }
▪ }
▪ ```
▪ - **Variables:**
▪ - **Flow :**
▪ - The program starts by asking the user for the number of rooms in the hotel.
▪ - The program enters an infinite loop w here it displays a menu and processes the user’s choice:
▪ - `1`: Check in a guest by prompting for the room number and guest name.
▪ This implementation provides a basic framew ork for managing a hotel’s room occupancy. It can be expanded w ith additional
▪ Thank you