Source Code in Python
import csv
import os
class HotelManagement:
def __init__(self):
self.customers = {} # Room number -> customer info
self.party_bookings = [] # List of party bookings
self.total_rooms = 20
self.rooms = ['Available'] * self.total_rooms
self.food_menu = {
'Soup': 50,
'Burger': 100,
'Pizza': 200,
'Noodles': 80,
'Meal': 250,
'Special Meal': 300
self.room_types = {
'Standard': 2000,
'Deluxe': 3000,
'Suite': 5000,
'Classic': 6000
self.load_data()
def load_data(self):
try:
with open('customers.csv', 'r') as file:
reader = csv.DictReader(file)
for row in reader:
room_number = int(row['room_number'])
self.customers[room_number] = row
self.rooms[room_number] = 'Booked'
with open('party_bookings.csv', 'r') as file:
reader = csv.DictReader(file)
self.party_bookings = list(reader)
except FileNotFoundError:
pass
def save_data(self):
with open('customers.csv', 'w', newline='') as file:
fieldnames = ['room_number', 'name', 'age', 'phone', 'dob', 'id_type', 'id_number',
'room_type', 'booking_days', 'bill']
writer = csv.DictWriter(file, fieldnames=fieldnames)
writer.writeheader()
for room_number, customer in self.customers.items():
customer['room_number'] = room_number
writer.writerow(customer)
with open('party_bookings.csv', 'w', newline='') as file:
fieldnames = ['venue', 'num_people', 'food_items', 'total_cost']
writer = csv.DictWriter(file, fieldnames=fieldnames)
writer.writeheader()
for booking in self.party_bookings:
writer.writerow(booking)
def book_room(self):
print("\nBooking a Room...")
try:
room_number = int(input("Enter room number to book (1-20): ")) - 1
if room_number < 0 or room_number >= self.total_rooms or self.rooms[room_number] !=
'Available':
print("Invalid or unavailable room number!")
return
print("\n--- Room Types ---")
for idx, (room_type, price) in enumerate(self.room_types.items(), 1):
print(f"{idx}. {room_type} - Rs. {price} per day")
room_choice = int(input("Select room type (1-4): "))
selected_room_type = list(self.room_types.keys())[room_choice - 1]
room_price = self.room_types[selected_room_type]
name = input("Enter customer name: ").strip()
age = input("Enter customer age: ").strip()
phone = input("Enter customer phone: ").strip()
dob = input("Enter customer DOB (DD/MM/YYYY): ").strip()
print("\n--- Identification Options ---")
print("1. Aadhar Card\n2. PAN Card\n3. Voter ID")
id_choice = int(input("Select ID type (1-3): "))
id_type = ["Aadhar Card", "PAN Card", "Voter ID"][id_choice - 1]
id_number = input(f"Enter {id_type} number: ").strip()
booking_days = int(input("Enter number of days for booking: "))
total_room_cost = room_price * booking_days
self.rooms[room_number] = 'Booked'
self.customers[room_number] = {
'name': name,
'age': age,
'phone': phone,
'dob': dob,
'id_type': id_type,
'id_number': id_number,
'room_type': selected_room_type,
'booking_days': booking_days,
'bill': total_room_cost
print(f"Room {room_number + 1} booked successfully for {name}!")
print(f"Total cost for {booking_days} days: Rs. {total_room_cost}")
self.save_data()
except Exception as e:
print(f"Error: {e}")
def modify_customer(self):
print("\nModifying Customer Details...")
try:
room_number = int(input("Enter room number to modify details (1-20): ")) - 1
if room_number not in self.customers:
print("No customer found in this room!")
return
print("Current Details:", self.customers[room_number])
name = input("Enter new name (leave blank to keep current): ").strip()
age = input("Enter new age (leave blank to keep current): ").strip()
phone = input("Enter new phone (leave blank to keep current): ").strip()
if name:
self.customers[room_number]['name'] = name
if age:
self.customers[room_number]['age'] = age
if phone:
self.customers[room_number]['phone'] = phone
print("Customer details updated successfully!")
self.save_data()
except Exception as e:
print(f"Error: {e}")
def search_customer(self):
print("\nSearching for a Customer...")
name = input("Enter customer name to search: ").strip()
found = False
for room, details in self.customers.items():
if details['name'].lower() == name.lower():
print(f"Customer found in room {room + 1}: {details}")
found = True
if not found:
print("No customer found with this name!")
def list_all_customers(self):
print("\nListing All Customers...")
if not self.customers:
print("No customers in the hotel!")
return
for room, details in self.customers.items():
print(f"Room {room + 1}: {details}")
def book_party(self):
print("\nBooking a Party...")
venue_options = ['Jupiter Hall', 'Bar']
print("\n--- Venue Options ---")
for idx, venue in enumerate(venue_options, 1):
print(f"{idx}. {venue}")
try:
venue_choice = int(input("Select a venue (1 or 2): "))
selected_venue = venue_options[venue_choice - 1]
num_people = int(input("Enter the number of people: "))
print("\n--- Food Menu ---")
for item, price in self.food_menu.items():
print(f"{item}: Rs. {price}")
total_food_cost = 0
selected_items = []
while True:
food_item = input("\nEnter a food item (or type 'done' to finish): ").title()
if food_item == 'Done':
break
if food_item not in self.food_menu:
print("Invalid item!")
continue
quantity = int(input(f"Enter quantity of {food_item}: "))
total_food_cost += self.food_menu[food_item] * quantity
selected_items.append((food_item, quantity))
if selected_items:
total_cost = total_food_cost * num_people
self.party_bookings.append({
'venue': selected_venue,
'num_people': num_people,
'food_items': selected_items,
'total_cost': total_cost
})
print(f"Party booked at {selected_venue} for {num_people} people!")
print(f"Total cost: Rs. {total_cost}")
self.save_data()
else:
print("No food items selected. Booking cancelled.")
except Exception as e:
print(f"Error: {e}")
def order_food(self):
print("\nOrdering Food...")
try:
room_number = int(input("Enter room number (1-20): ")) - 1
if room_number not in self.customers:
print("No customer found in this room!")
return
print("\n--- Food Menu ---")
for item, price in self.food_menu.items():
print(f"{item}: Rs. {price}")
total_cost = 0
while True:
food_item = input("\nEnter food item (or type 'done' to finish): ").title()
if food_item == 'Done':
break
if food_item not in self.food_menu:
print("Invalid item!")
continue
quantity = int(input(f"Enter quantity for {food_item}: "))
total_cost += self.food_menu[food_item] * quantity
if total_cost > 0:
self.customers[room_number]['bill'] += total_cost
print(f"Food order added. Total: Rs. {total_cost}")
self.save_data()
else:
print("No items were ordered.")
except Exception as e:
print(f"Error: {e}")
def display_party_bookings(self):
print("\nDisplaying All Party Bookings...")
if not self.party_bookings:
print("No party bookings!")
return
for i, booking in enumerate(self.party_bookings, 1):
print(f"Booking {i}: {booking}")
def pay_bill(self):
print("\nPaying Bill...")
try:
room_number = int(input("Enter room number (1-20): ")) - 1
if room_number not in self.customers:
print("No customer found in this room!")
return
bill = int(self.customers[room_number]['bill'])
print(f"Current bill: Rs. {bill}")
amount = int(input("Enter amount to pay: "))
if amount > bill:
print("Amount exceeds the total bill!")
return
self.customers[room_number]['bill'] -= amount
print(f"Payment successful! Remaining bill: Rs. {self.customers[room_number]['bill']}")
self.save_data()
except Exception as e:
print(f"Error: {e}")
def checkout_customer(self):
print("\nChecking Out Customer...")
try:
room_number = int(input("Enter room number (1-20): ")) - 1
if room_number not in self.customers:
print("No customer found in this room!")
return
print(f"Checking out {self.customers[room_number]['name']}.")
print(f"Total bill: Rs. {self.customers[room_number]['bill']}")
del self.customers[room_number]
self.rooms[room_number] = 'Available'
self.save_data()
except Exception as e:
print(f"Error: {e}")
def delete_customer(self):
print("\nDeleting Customer...")
try:
room_number = int(input("Enter room number (1-20): ")) - 1
if room_number not in self.customers:
print("No customer found in this room!")
return
del self.customers[room_number]
self.rooms[room_number] = 'Available'
print("Customer record deleted successfully.")
self.save_data()
except Exception as e:
print(f"Error: {e}")
def menu(self):
while True:
print("\n=== Hotel Management System ===")
print("1. Book Room")
print("2. Modify Customer Details")
print("3. Search Customer")
print("4. List All Customers")
print("5. Book Party")
print("6. Order Food")
print("7. Display Party Bookings")
print("8. Pay Bill")
print("9. Checkout Customer")
print("10. Delete Customer")
print("11. Exit")
try:
choice = int(input("Enter your choice: "))
if choice == 1:
self.book_room()
elif choice == 2:
self.modify_customer()
elif choice == 3:
self.search_customer()
elif choice == 4:
self.list_all_customers()
elif choice == 5:
self.book_party()
elif choice == 6:
self.order_food()
elif choice == 7:
self.display_party_bookings()
elif choice == 8:
self.pay_bill()
elif choice == 9:
self.checkout_customer()
elif choice == 10:
self.delete_customer()
elif choice == 11:
print("Exiting system. Goodbye!")
break
else:
print("Invalid choice! Please try again.")
except ValueError:
print("Invalid input! Please enter a number.")
if __name__ == "__main__":
hotel = HotelManagement()
hotel.menu()