-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathcar_rental_system_demo.py
42 lines (35 loc) · 1.79 KB
/
car_rental_system_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from rental_system import RentalSystem
from car import Car
from customer import Customer
from datetime import date, timedelta
class CarRentalSystemDemo:
@staticmethod
def run():
rental_system = RentalSystem.get_instance()
# Add cars to the rental system
rental_system.add_car(Car("Toyota", "Camry", 2022, "ABC123", 50.0))
rental_system.add_car(Car("Honda", "Civic", 2021, "XYZ789", 45.0))
rental_system.add_car(Car("Ford", "Mustang", 2023, "DEF456", 80.0))
# Create customers
customer1 = Customer("John Doe", "[email protected]", "DL1234")
customer2 = Customer("Jane Smith", "[email protected]", "DL5678")
# Make reservations
start_date = date.today()
end_date = start_date + timedelta(days=3)
available_cars = rental_system.search_cars("Toyota", "Camry", start_date, end_date)
if available_cars:
selected_car = available_cars[0]
reservation = rental_system.make_reservation(customer1, selected_car, start_date, end_date)
if reservation is not None:
payment_success = rental_system.process_payment(reservation)
if payment_success:
print(f"Reservation successful. Reservation ID: {reservation.get_reservation_id()}")
else:
print("Payment failed. Reservation canceled.")
rental_system.cancel_reservation(reservation.get_reservation_id())
else:
print("Selected car is not available for the given dates.")
else:
print("No available cars found for the given criteria.")
if __name__ == "__main__":
CarRentalSystemDemo.run()