BlackSunFL

main.py

Dec 2nd, 2024
432
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.88 KB | None | 0 0
  1. from PremiumCustomer import PremiumCustomer
  2. from StandardCustomer import StandardCustomer
  3. from reservation import Reservation
  4.  
  5. print("Welcome to Lemon Tree Hotel Reservation System")
  6.  
  7. # List to store all reservations
  8. Reservation_list = []
  9.  
  10. # Function to enter a new reservation
  11. def enter_reservation():
  12.     first_name = input("Enter the first name: ")
  13.     last_name = input("Enter the last name: ")
  14.     mobile_number = input("Enter the mobile number: ")
  15.     email = input("Enter the email: ")
  16.     age = int(input("Enter the age: "))
  17.     address = input("Enter the address: ")
  18.     profile = input("Enter the profile type S = Standard or P = Premium: ")
  19.     purpose = input("Enter purpose (Leisure or Business): ")
  20.     room_type = input("Enter room type (Single or Double): ")
  21.     num_rooms = int(input("Enter the number of rooms needed: "))
  22.     checkin = input("Enter the check-in date (DD-MM-YYYY): ")
  23.     checkout = input("Enter the check-out date (DD-MM-YYYY): ")
  24.     status = "Active"
  25.  
  26.     if profile == "S":
  27.         customer = StandardCustomer(first_name, last_name, mobile_number, email, address, age, "Standard")
  28.     elif profile == "P":
  29.         customer = PremiumCustomer(first_name, last_name, mobile_number, email, address, age, "Premium")
  30.     else:
  31.         customer = None
  32.  
  33.     # Create a Reservation object and link it to the customer
  34.     reservation = Reservation(checkin, checkout, room_type, num_rooms, purpose, customer)
  35.     reservation.set_status(status)
  36.  
  37.     # Add the reservation to the Reservation list
  38.     Reservation_list.append(reservation)
  39.     print("Reservation successfully added!\n")
  40.  
  41. # Function to print all reservations
  42. def print_all_reservations():
  43.     if not Reservation_list:
  44.         print("No reservations found.")
  45.     else:
  46.         for idx, reservation in enumerate(Reservation_list, start=1):
  47.             print(f"\nReservation {idx}:")
  48.             print(f"Customer: {reservation.get_customer().get_first_name()} {reservation.get_customer().get_last_name()}")
  49.             print(f"Check-in Date: {reservation.get_checkin_date()}")
  50.             print(f"Check-out Date: {reservation.get_checkout_date()}")
  51.             print(f"Room Type: {reservation.get_room_type()}")
  52.             print(f"Number of Rooms: {reservation.get_num_rooms()}")
  53.             print(f"Purpose: {reservation.get_purpose()}")
  54.             print(f"Status: {reservation.get_status()}")
  55.  
  56. # Function to cancel a reservation
  57. def cancel_reservation():
  58.     if not Reservation_list:
  59.         print("No reservations available to cancel.")
  60.     else:
  61.         print_all_reservations()
  62.         try:
  63.             reservation_number = int(input("\nEnter the reservation number you want to cancel: "))
  64.             if 1 <= reservation_number <= len(Reservation_list):
  65.                 # Set the status of the selected reservation to "Cancelled"
  66.                 Reservation_list[reservation_number - 1].set_status("Cancelled")
  67.                 print(f"Reservation {reservation_number} has been successfully cancelled.")
  68.             else:
  69.                 print("Invalid reservation number. Please try again.")
  70.         except ValueError:
  71.             print("Invalid input. Please enter a valid reservation number.")
  72.  
  73. # Menu-driven program
  74. while True:
  75.     print("\nOptions:")
  76.     print("1. Enter Reservation")
  77.     print("2. Print All Reservations")
  78.     print("3. Cancel a Reservation")
  79.     print("4. Exit")
  80.  
  81.     try:
  82.         option = int(input("Choose an option: "))
  83.  
  84.         if option == 1:
  85.             enter_reservation()
  86.         elif option == 2:
  87.             print_all_reservations()
  88.         elif option == 3:
  89.             cancel_reservation()
  90.         elif option == 4:
  91.             print("Exiting the system. Thank you!")
  92.             break
  93.         else:
  94.             print("Invalid option. Please choose a valid option.")
  95.     except ValueError:
  96.         print("Invalid input. Please enter a valid number.")
  97.  
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment