BlackSunFL icon

main.py

BlackSunFL | PRO | 12/02/24 01:44:01 PM UTC | 0 ⭐ | 300 👁️ | Never ⏰ | []
Python |

3.88 KB

|

None

|

0 👍

/

0 👎

from PremiumCustomer import PremiumCustomer
from StandardCustomer import StandardCustomer
from reservation import Reservation
 
print("Welcome to Lemon Tree Hotel Reservation System")
 
# List to store all reservations
Reservation_list = []
 
# Function to enter a new reservation
def enter_reservation():
    first_name = input("Enter the first name: ")
    last_name = input("Enter the last name: ")
    mobile_number = input("Enter the mobile number: ")
    email = input("Enter the email: ")
    age = int(input("Enter the age: "))
    address = input("Enter the address: ")
    profile = input("Enter the profile type S = Standard or P = Premium: ")
    purpose = input("Enter purpose (Leisure or Business): ")
    room_type = input("Enter room type (Single or Double): ")
    num_rooms = int(input("Enter the number of rooms needed: "))
    checkin = input("Enter the check-in date (DD-MM-YYYY): ")
    checkout = input("Enter the check-out date (DD-MM-YYYY): ")
    status = "Active"
 
    if profile == "S":
        customer = StandardCustomer(first_name, last_name, mobile_number, email, address, age, "Standard")
    elif profile == "P":
        customer = PremiumCustomer(first_name, last_name, mobile_number, email, address, age, "Premium")
    else:
        customer = None
 
    # Create a Reservation object and link it to the customer
    reservation = Reservation(checkin, checkout, room_type, num_rooms, purpose, customer)
    reservation.set_status(status)
 
    # Add the reservation to the Reservation list
    Reservation_list.append(reservation)
    print("Reservation successfully added!\n")
 
# Function to print all reservations
def print_all_reservations():
    if not Reservation_list:
        print("No reservations found.")
    else:
        for idx, reservation in enumerate(Reservation_list, start=1):
            print(f"\nReservation {idx}:")
            print(f"Customer: {reservation.get_customer().get_first_name()} {reservation.get_customer().get_last_name()}")
            print(f"Check-in Date: {reservation.get_checkin_date()}")
            print(f"Check-out Date: {reservation.get_checkout_date()}")
            print(f"Room Type: {reservation.get_room_type()}")
            print(f"Number of Rooms: {reservation.get_num_rooms()}")
            print(f"Purpose: {reservation.get_purpose()}")
            print(f"Status: {reservation.get_status()}")
 
# Function to cancel a reservation
def cancel_reservation():
    if not Reservation_list:
        print("No reservations available to cancel.")
    else:
        print_all_reservations()
        try:
            reservation_number = int(input("\nEnter the reservation number you want to cancel: "))
            if 1 <= reservation_number <= len(Reservation_list):
                # Set the status of the selected reservation to "Cancelled"
                Reservation_list[reservation_number - 1].set_status("Cancelled")
                print(f"Reservation {reservation_number} has been successfully cancelled.")
            else:
                print("Invalid reservation number. Please try again.")
        except ValueError:
            print("Invalid input. Please enter a valid reservation number.")
 
# Menu-driven program
while True:
    print("\nOptions:")
    print("1. Enter Reservation")
    print("2. Print All Reservations")
    print("3. Cancel a Reservation")
    print("4. Exit")
 
    try:
        option = int(input("Choose an option: "))
 
        if option == 1:
            enter_reservation()
        elif option == 2:
            print_all_reservations()
        elif option == 3:
            cancel_reservation()
        elif option == 4:
            print("Exiting the system. Thank you!")
            break
        else:
            print("Invalid option. Please choose a valid option.")
    except ValueError:
        print("Invalid input. Please enter a valid number.")
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎