🌿 Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms"

A Hotel Management System built with C++ is a great way to understand object-oriented programming and data management. This project includes essential features such as room reservation, displaying room details, checking out, and bill calculation.
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class Room {
public:
int roomNumber;
string roomType; // eg. single, double, suite
double pricePerNight;
bool isAvailable;
Room(int num, string type, double price) {
roomNumber = num;
roomType = type;
pricePerNight = price;
isAvailable = true;
}
void displayRoomDetails() {
cout << "Room Number: " << roomNumber << endl;
cout << "Room Type: " << roomType << endl;
cout << "Price per night: $" << pricePerNight << endl;
cout << "Availability: " << (isAvailable ? "Available" : "Booked") << endl;
}
};
class Customer {
public:
string name;
string contactNumber;
int bookedRoom;
Customer(string customerName, string contact, int roomNum) {
name = customerName;
contactNumber = contact;
bookedRoom = roomNum;
}
void displayCustomerDetails() {
cout << "Customer Name: " << name << endl;
cout << "Contact Number: " << contactNumber << endl;
cout << "Booked Room: " << bookedRoom << endl;
}
};
class Hotel {
private:
vector<Room> rooms;
vector<Customer> customers;
public:
void addRoom(Room room) {
rooms.push_back(room);
}
void displayAvailableRooms() {
cout << "\nAvailable Rooms:\n";
for (Room &room : rooms) {
if (room.isAvailable) {
room.displayRoomDetails();
cout << "-----------------" << endl;
}
}
}
void bookRoom(string customerName, string contactNumber, int roomNumber) {
for (Room &room : rooms) {
if (room.roomNumber == roomNumber) {
if (room.isAvailable) {
room.isAvailable = false;
customers.emplace_back(customerName, contactNumber, roomNumber);
cout << "Room " << roomNumber << " successfully booked by " << customerName << ".\n";
} else {
cout << "Room " << roomNumber << " is already booked.\n";
}
return;
}
}
cout << "Room not found!\n";
}
void checkOut(int roomNumber) {
for (Room &room : rooms) {
if (room.roomNumber == roomNumber) {
if (!room.isAvailable) {
room.isAvailable = true;
for (size_t i = 0; i < customers.size(); ++i) {
if (customers[i].bookedRoom == roomNumber) {
customers.erase(customers.begin() + i);
break;
}
}
cout << "Room " << roomNumber << " successfully checked out.\n";
return;
} else {
cout << "Room " << roomNumber << " is already available.\n";
return;
}
}
}
cout << "Room not found!\n";
}
void displayCustomers() {
cout << "\nCurrent Customers:\n";
for (Customer &customer : customers) {
customer.displayCustomerDetails();
cout << "----------------------" << endl;
}
}
};
int main() {
Hotel hotel;
hotel.addRoom(Room(101, "Single", 50.0));
hotel.addRoom(Room(102, "Double", 75.0));
hotel.addRoom(Room(103, "Suite", 150.0));
int choice;
do {
cout << "\n-----Hotel Management System-----\n";
cout << "1. Display Available Rooms\n";
cout << "2. Book a Room\n";
cout << "3. Check Out\n";
cout << "4. Display Customer Details\n";
cout << "5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
hotel.displayAvailableRooms();
break;
case 2: {
string name, contact;
int roomNum;
cout << "Enter your name: ";
cin.ignore();
getline(cin, name);
cout << "Enter your contact number: ";
getline(cin, contact);
cout << "Enter room number to book: ";
cin >> roomNum;
hotel.bookRoom(name, contact, roomNum);
break;
}
case 3: {
int roomNum;
cout << "Enter room number to check out: ";
cin >> roomNum;
hotel.checkOut(roomNum);
break;
}
case 4:
hotel.displayCustomers();
break;
case 5:
cout << "Exiting the system. Thank you!\n";
break;
default:
cout << "Invalid choice! Please try again.\n";
}
} while (choice != 5);
return 0;
}
Many small hotels initially handle reservations manually, leading to overbooking and mismanagement. A simple C++ hotel management system allows hotels to track available rooms, manage reservations, and improve efficiency.
Hostels and dormitories can implement a similar system to assign rooms to students or guests dynamically. Instead of hotel rooms, the system can manage hostel accommodations, ensuring fair allocation based on availability.
Resorts often deal with seasonal spikes in bookings. A C++ hotel management system can help streamline reservations, prevent double bookings, and track customer check-ins and check-outs.
Implement a locking mechanism that marks a room as temporarily unavailable when a booking process is initiated.
Use a hash map or binary search tree to store customer records, making retrieval and updates faster.
Integrate automatic bill generation based on room type, number of nights, and additional services.
A C++ hotel management system can be adapted for various real-world applications. By implementing structured data handling and problem-solving approaches, such systems can significantly improve efficiency in hospitality management.
Comments
Post a Comment