Пример #1
0
CRS.add_car(PremiumCar("Audi", "model x", 2019, 22))
CRS.add_car(PremiumCar("Audi", "A4", 2019, 23))
CRS.add_car(PremiumCar("Audi", "S class", 2019, 24))

#
print("\n\n~~~ Print all customers ~~~")
for customer in CRS.customers:
    print(customer)

print("\n\n~~~ Print all cars ~~~")
for car in CRS.cars:
    print(car)

print("\n\n~~~ Make first booking ~~~")
customer = CRS.get_customer(3)
car = CRS.get_car(5)
CRS.make_booking(customer, car, 7, Location("Sydney", "Canberra"))

print("\n\n~~~ Make second booking ~~~")
customer = CRS.get_customer(2)
car = CRS.get_car(21)
CRS.make_booking(customer, car, 12, Location("Earth", "Moon"))

print("\n\n~~~ Print all bookings ~~~")
for booking in CRS.bookings:
    print(booking, end="\n\n")

######################################################
# Do our own tests
######################################################
Пример #2
0
for name in ["Tesla", "Audi"]:
    for model in ["model x", "A4", "S class"]:
        system.add_car(PremiumCar(name, model, rego_generator.next()))

for name in ["Matt", "Isaac", "Taylor"]:
    system.add_customer(Customer(name, licence_generator.next()))

print('~~~ Print all customers ~~~')
print('\n'.join(str(c) for c in system.customers))

print('\n~~~ Print all cars ~~~')
print('\n'.join(str(c) for c in system.cars))

print('\n\n~~~ Make first booking ~~~')
user = system.get_customer(3)
car = system.get_car(5)

year1 = 2018
month1 = 12
day1 = 1

year2 = 2018
month2 = 12
day2 = 5

start_date = f'{year1}-{month1}-{day1}'
end_date = f'{year2}-{month2}-{day2}'

booking = system.make_booking(user, car, start_date, end_date, 'Sydney',
                              'Canberra')