0% found this document useful (0 votes)
8 views2 pages

Hotel Management Code

Uploaded by

kumaranhirithick
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)
8 views2 pages

Hotel Management Code

Uploaded by

kumaranhirithick
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/ 2

class Hotel:

def __init__(self, name, rooms):


self.name = name
self.rooms = rooms
self.room_prices = {
'Single': 1000,
'Double': 1500,
'Suite': 3000
}

def check_availability(self):
print("\nRoom Availability:")
for room_type, available_rooms in self.rooms.items():
print(f"{room_type} Room(s): {available_rooms} available")

def book_room(self, room_type, num_rooms):


if room_type in self.rooms:
available_rooms = self.rooms[room_type]
if available_rooms >= num_rooms:
self.rooms[room_type] -= num_rooms
total_cost = self.room_prices[room_type] * num_rooms
print(f"\nSuccessfully booked {num_rooms} {room_type} room(s).")
print(f"Total cost: {total_cost} INR")
else:
print("\nSorry, not enough rooms available.")
else:
print("\nInvalid room type.")

def checkout(self, room_type, num_rooms):


if room_type in self.rooms:
self.rooms[room_type] += num_rooms
print(f"\nChecked out {num_rooms} {room_type} room(s).")
else:
print("\nInvalid room type.")

def main():
hotel_name = "Sunshine Hotel"
available_rooms = {
'Single': 10,
'Double': 5,
'Suite': 2
}

hotel = Hotel(hotel_name, available_rooms)

print(f"Welcome to {hotel_name}!\n")

while True:
print("\n1. Check Room Availability")
print("2. Book Room")
print("3. Checkout")
print("4. Exit")

choice = int(input("\nEnter your choice: "))

if choice == 1:
hotel.check_availability()
elif choice == 2:
room_type = input("Enter room type (Single/Double/Suite): ").capitalize()
num_rooms = int(input(f"How many {room_type} rooms would you like to book? "))
hotel.book_room(room_type, num_rooms)
elif choice == 3:
room_type = input("Enter room type (Single/Double/Suite): ").capitalize()
num_rooms = int(input(f"How many {room_type} rooms would you like to checkout? "))
hotel.checkout(room_type, num_rooms)
elif choice == 4:
print("\nThank you for visiting!")
break
else:
print("\nInvalid choice! Please try again.")

if __name__ == "__main__":
main()

You might also like