def main(): import random cervelo = Bicycle("Cervelo S3", 18, 2700) evo = Bicycle("Cannondale SuperSix Evo", 14, 1500) dogma = Bicycle("Pinarello Dogma", 16, 4000) thunderbolt = Bicycle("Rocky Mountain Thunderbolt", 26, 2000) scalpel = Bicycle("Cannondale Scalpel", 25, 3500) bolide = Bicycle("Pinarello Bolide", 20, 8000) bikes = [cervelo, evo, dogma, thunderbolt, scalpel, bolide] the_bike_shop = BikeShop("The Bike Shop", bikes) print("Welcome to {}! This is what we have in our inventory:".format(the_bike_shop.name)) print(" ") for item in the_bike_shop.inventory: print(item.model) print(" ") mitchell = Customer("Mitchell", 4000, []) emily = Customer("Emily", 10000, []) lee = Customer("Lee", 6000, []) customers = [mitchell, emily, lee] for customer in customers: print(" ") print("*Bikes {} can afford*".format(customer.name)) print(" ") for index, bike in enumerate(customer.potential_bikes(the_bike_shop)): print(str(index + 1) + ".", (bike.model + ","), ("$" + str(the_bike_shop.msrp(bike)))) print(" ") available_bikes = customer.potential_bikes(the_bike_shop) if len(available_bikes) > 0: for item in available_bikes: bike = random.choice(available_bikes) customer.purchase(bike, the_bike_shop) print("{}'s remaining balance: ".format(customer.name), customer.budget) break
# creates six bikes that are made of wheels and frames bike1 = Bike(wheel1, Alu, "bike1", "Triumph Bikes") bike2 = Bike(wheel2, Carbon, "bike2", "Zelda Bikes") bike3 = Bike(wheel3, SS, "bike3", "Triumph Bikes") bike4 = Bike(wheel1, SS, "bike4", "Zelda Bikes") bike5 = Bike(wheel2, Carbon, "bike5", "Triumph Bikes") bike6 = Bike(wheel2, Alu, "bike6", "Zelda Bikes") # a list of the bikes bikes = [bike1, bike2, bike3, bike4, bike5, bike6] sam = Customer("Sam", 400) bill = Customer("Bill", 1000) # creates a bike shop- with a three bike objects in it. james_bike_shop = BikeShop("James's bicycle emporium", 1.2, [bike1, bike2, bike3]) james_bike_shop.print_inventory() james_bike_shop.total_wholesale_cost() james_bike_shop.print_costs() james_bike_shop.print_affoardable_bikes(sam) print "kawasaki" print "sam money before", sam.money james_bike_shop.buy_a_bike(sam, "bike1") print "honda" james_bike_shop.buy_a_bike(sam, "bike1") print "sam money after", sam.money anthonys_bike_shop = BikeShop("Anthony's racing bicyles", 1.25, [bike4, bike5, bike6]) anthonys_bike_shop.print_inventory()