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

Group Project Class 12

The document defines a Hotel class that manages room bookings, including adding rooms, checking availability, booking rooms, and viewing current bookings. It includes a main function that provides a simple command-line interface for users to interact with the hotel management system. The system allows users to check available rooms, book a room for a guest, view all bookings, or exit the program.

Uploaded by

Vinayak Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Group Project Class 12

The document defines a Hotel class that manages room bookings, including adding rooms, checking availability, booking rooms, and viewing current bookings. It includes a main function that provides a simple command-line interface for users to interact with the hotel management system. The system allows users to check available rooms, book a room for a guest, view all bookings, or exit the program.

Uploaded by

Vinayak Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

class Hotel:

def __init__(self):

self.rooms = {}

self.bookings = {}

def add_room(self, room_number, room_type):

self.rooms[room_number] = room_type

self.bookings[room_number] = None

def check_availability(self):

available_rooms = [room for room, booking in self.bookings.items() if booking is None]

return available_rooms

def book_room(self, room_number, guest_name):

if room_number in self.bookings and self.bookings[room_number] is None:

self.bookings[room_number] = guest_name

print(f"Room {room_number} has been booked for {guest_name}.")

else:

print(f"Room {room_number} is not available.")

def view_bookings(self):

for room, guest in self.bookings.items():

if guest:

print(f"Room {room} is booked by {guest}.")

else:

print(f"Room {room} is available.")

def main():

hotel = Hotel()

# Adding rooms to the hotel


hotel.add_room(101, "Single")

hotel.add_room(102, "Double")

hotel.add_room(103, "Suite")

while True:

print("\nHotel Management System")

print("1. Check Availability")

print("2. Book Room")

print("3. View Bookings")

print("4. Exit")

choice = input("Enter your choice: ")

if choice == '1':

available_rooms = hotel.check_availability()

if available_rooms:

print("Available rooms:", available_rooms)

else:

print("No rooms available.")

elif choice == '2':

room_number = int(input("Enter room number to book: "))

guest_name = input("Enter guest name: ")

hotel.book_room(room_number, guest_name)

elif choice == '3':

hotel.view_bookings()

elif choice == '4':

print("Exiting the system.")

break
else:

print("Invalid choice. Please try again.")

if __name__ == "__main__":

main()

You might also like