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

Image
  🌿  Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms" 🧭  1. Introduction: Farming in the Age of Climate Change In a world where clean water is more precious than gold, efficient  rainwater harvesting and plant care systems  are no longer optional — they’re essential. Smart farming doesn’t mean just automating irrigation. It means combining  robotic drones, environmental sensors, and intelligent scheduling  to build a garden that practically takes care of itself. In this guide, we build a  fully functional Garden Manager System  using  C++  that: Captures and conserves rainwater Uses  robotic drones and sensors  to monitor crop health Integrates a  real-time UI  with progress bars and alerts Includes  timers  for scheduling plant growth and drone tasks Plays  interactive sounds  based on crop state and events Whether you'r...

C++ Projects: Hotel Management System

C++ Hotel Management System

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.

Code to Build the Project

Header Files

#include<iostream>
#include<string>
#include<vector>
using namespace std;

Definition of Classes

Room Class

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;
    }
};

Customer Class

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;
    }
};

Hotel Class

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;
        }
    }
};

Main Function

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;
}

Real-World Applications and Case Studies

Small Hotel Chains Automating Room Bookings

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.

Hostel Room Allocation System

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.

Resort or Holiday Homes Management

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.

Problem-Solving Approaches

Handling Room Overbooking

Implement a locking mechanism that marks a room as temporarily unavailable when a booking process is initiated.

Managing Customer Data Efficiently

Use a hash map or binary search tree to store customer records, making retrieval and updates faster.

Automating Bill Calculation

Integrate automatic bill generation based on room type, number of nights, and additional services.

Conclusion

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

Popular posts from this blog

C++ Projects: Basic Traffic Management System

C++ Projects: Book Shop Management System

C++ Projects: Password Manager