Hms Final
Hms Final
Introduction:
This article discusses a C++ hotel management project that automates various
functions essential for hotel operations. The system offers a range of features,
including reserving rooms, reviewing customer information, modifying or
removing client records, and viewing all assigned rooms. By providing these
functionalities, the system enhances the efficiency of hotel management and
improves customer service. It ensures that hotel staff can easily handle
reservations and manage guest details, streamlining day-to-day operations and
improving overall organization.
The development of this project employs two key C++ concepts: classes and file
handling. Classes are used to encapsulate the data and behaviours associated
with hotel entities, such as customers and rooms, promoting modularity and
reusability in the code. File handling is crucial for maintaining persistent
records, allowing customer and room information to be stored in files that can
be accessed and updated as needed. By leveraging these concepts, the hotel
management system provides a robust and scalable solution for managing hotel
operations effectively.
1 NMPI/CO3K/2024-25
Hotel management systemin C+ +
Features of Hotel
• Show all rooms
• Book a room
• Show all bookings
• Exit
Advantages:
1. Performance: C++ offers fast and efficient execution, suitable
for real-time hotel operations.
2. Object-Oriented Programming (OOP): C++ allows modular
system design with classes for rooms, customers, etc.
3. Memory Management: Provides control over memory usage,
ensuring efficient resource handling.
4. Extensibility: The system can easily be extended with new
features or modules.
5. Cross-platform: C++ can be compiled for multiple operating
systems, offering deployment flexibility.
2 NMPI/CO3K/2024-25
Hotel management systemin C+ +
Source Code
#include <iostream>
#include <vector>
#include <string>
class Room {
int roomNumber;
std::string roomType;
bool isAvailable;
double price;
public:
Room(int number, std::string type, double price)
: roomNumber(number), roomType(type), isAvailable(true),
price(price) {}
int getRoomNumber() const { return roomNumber; }
std::string getRoomType() const { return roomType; }
bool checkAvailability() const { return isAvailable; }
void bookRoom() { isAvailable = false; }
void freeRoom() { isAvailable = true; }
double getPrice() const { return price; }
void displayDetails() const {
std::cout << "Room Number: " << roomNumber << ", Type: "
<< roomType
<< ", Price: $" << price << ", Available: " <<
(isAvailable ? "Yes" : "No") << std::endl;
3 NMPI/CO3K/2024-25
Hotel management systemin C+ +
}
};
class Guest {
std::string name;
std::string contact;
public:
Guest(std::string guestName, std::string guestContact)
: name(guestName), contact(guestContact) {}
std::string getName() const { return name; }
std::string getContact() const { return contact; }
void displayDetails() const {
std::cout << "Name: " << name << ", Contact: " << contact <<
std::endl;
}
};
class Booking {
Room &room;
Guest &guest;
int stayDuration;
double totalBill;
public:
Booking(Room &r, Guest &g, int days)
: room(r), guest(g), stayDuration(days) {
room.bookRoom();
4 NMPI/CO3K/2024-25
Hotel management systemin C+ +
5 NMPI/CO3K/2024-25
Hotel management systemin C+ +
guests.emplace_back(name, contact);
}
Room* findAvailableRoom(std::string type) {
for (auto &room : rooms) {
if (room.getRoomType() == type &&
room.checkAvailability()) {
return &room;
}
}
return nullptr;
}
void bookRoom(std::string roomType, std::string guestName,
std::string guestContact, int days) {
Room* room = findAvailableRoom(roomType);
if (room) {
guests.emplace_back(guestName, guestContact);
Booking booking(*room, guests.back(), days);
bookings.push_back(booking);
std::cout << "Room booked successfully!" << std::endl;
} else {
std::cout << "Sorry, no available rooms of the specified type."
<< std::endl;
}
}
6 NMPI/CO3K/2024-25
Hotel management systemin C+ +
7 NMPI/CO3K/2024-25
Hotel management systemin C+ +
8 NMPI/CO3K/2024-25
Hotel management systemin C+ +
Output:
9 NMPI/CO3K/2024-25
Hotel management systemin C+ +
Conclusion:
10 NMPI/CO3K/2024-25
Hotel management systemin C+ +
11 NMPI/CO3K/2024-25
Hotel management systemin C+ +
Reference:
https://www.javatpoint.com/
https://www.cppbuzz.com/
www.google.com
12 NMPI/CO3K/2024-25