0% found this document useful (0 votes)
14 views

Hotel_Booking_System_Report

Uploaded by

nithiinkumar20
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Hotel_Booking_System_Report

Uploaded by

nithiinkumar20
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Hotel Booking System - Python OOP

1. Introduction
This report explains the implementation of a Hotel Booking System using Python Object-
Oriented Programming (OOP). The system allows hotels to manage their rooms, check
availability, book rooms, and release rooms efficiently. The code leverages OOP principles
such as classes, objects, and methods.

2. Code Overview
The Python script consists of two main classes: HotelRoom and Hotel. Each class represents
a distinct aspect of the hotel booking system.

2.1. HotelRoom Class


The HotelRoom class defines individual rooms in a hotel with attributes like room number,
type, price, and availability. It includes methods to book and release the room.

2.2. Hotel Class


The Hotel class manages a collection of HotelRoom objects. It includes methods to add
rooms, find available rooms by type, book a specific room, and release a room.

3. Features
- Add rooms to the hotel.
- Check availability of rooms based on type.
- Book a room using its room number.
- Release a booked room.

4. Code Explanation
Below is the Python code implementing the Hotel Booking System:

class HotelRoom:
def __init__(self, room_number, room_type, price_per_night):
self.room_number = room_number
self.room_type = room_type
self.price_per_night = price_per_night
self.is_available = True

def book_room(self):
if self.is_available:
self.is_available = False
return True
else:
return False
def release_room(self):
self.is_available = True

class Hotel:
def __init__(self, name, location):
self.name = name
self.location = location
self.rooms = []

def add_room(self, room):


self.rooms.append(room)

def find_available_rooms(self, room_type):


return [room for room in self.rooms if room.room_type == room_type and
room.is_available]

def book_room(self, room_number):


for room in self.rooms:
if room.room_number == room_number and room.is_available:
if room.book_room():
return f"Room {room_number} successfully booked."
return f"Room {room_number} is not available."

def release_room(self, room_number):


for room in self.rooms:
if room.room_number == room_number:
room.release_room()
return f"Room {room_number} is now available."
return f"Room {room_number} not found."

5. Example Usage
The script demonstrates the functionality with an example. It adds three rooms to a hotel,
checks availability, books a room, and releases it. Below is a sample output:

Available rooms (Single): [101]


Room 101 successfully booked.
Room 101 is not available.
Room 101 is now available.

6. Conclusion
This Python-based Hotel Booking System simplifies room management for hotels. The
modular design allows easy scalability and integration into larger systems.

You might also like