コード例 #1
0
def rental_fixture():
    system = CarRentalSystem()
    rego_generator = IdGenerator()
    licence_generator = IdGenerator()

    for name in ["Mazda", "Holden", "Ford"]:
        for model in ["Falcon", "Commodore"]:
            system.add_car(SmallCar(name, model, rego_generator.next()))
            system.add_car(MediumCar(name, model, rego_generator.next()))
            system.add_car(LargeCar(name, model, rego_generator.next()))

    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()))

    return system
コード例 #2
0
ファイル: client.py プロジェクト: mcluvine/UNSW-COMP1531
from customer import Customer
from car import SmallCar, MediumCar, LargeCar, PremiumCar
from car_rental_system import CarRentalSystem
from location import Location

# Populate the system
CRS = CarRentalSystem()

# Add customers
CRS.add_customer(Customer("Matt", 18, 1, "*****@*****.**"))
CRS.add_customer(Customer("Isaac", 31, 2, "*****@*****.**"))
CRS.add_customer(Customer("Taylor", 27, 3, "*****@*****.**"))

# Add cars
CRS.add_car(SmallCar("Mazda", "Falcon", 2019, 1))
CRS.add_car(MediumCar("Mazda", "Falcon", 2019, 2))
CRS.add_car(LargeCar("Mazda", "Falcon", 2019, 3))
CRS.add_car(SmallCar("Mazda", "Commodore", 2019, 4))
CRS.add_car(MediumCar("Mazda", "Commodore", 2019, 5))
CRS.add_car(LargeCar("Mazda", "Commodore", 2019, 6))
CRS.add_car(SmallCar("Holden", "Falcon", 2019, 7))
CRS.add_car(MediumCar("Holden", "Falcon", 2019, 8))
CRS.add_car(LargeCar("Holden", "Falcon", 2019, 9))
CRS.add_car(SmallCar("Holden", "Commodore", 2019, 10))
CRS.add_car(MediumCar("Holden", "Commodore", 2019, 11))
CRS.add_car(LargeCar("Holden", "Commodore", 2019, 12))
CRS.add_car(SmallCar("Ford", "Falcon", 2019, 13))
CRS.add_car(MediumCar("Ford", "Falcon", 2019, 14))
CRS.add_car(LargeCar("Ford", "Falcon", 2019, 15))
CRS.add_car(SmallCar("Ford", "Commodore", 2019, 16))
CRS.add_car(MediumCar("Ford", "Commodore", 2019, 17))
コード例 #3
0
class IdGenerator():
    def __init__(self):
        self._id = 0

    def next(self):
        self._id += 1
        return self._id


rego_generator = IdGenerator()
licence_generator = IdGenerator()

for name in ["Mazda", "Holden", "Ford"]:
    for model in ["Falcon", "Commodore"]:
        system.add_car(SmallCar(name, model, rego_generator.next()))
        system.add_car(MediumCar(name, model, rego_generator.next()))
        system.add_car(LargeCar(name, model, rego_generator.next()))

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))