# Create a bike shop with 6 models in stock and 20% markup CycleWorld = BikeShop("Cycle World", {Schwinn: 5, Huffy: 10, Vilano: 7, Diamondback: 6, Kestrel: 2, Windsor: 8 }, 0.20) # Create 3 customers with funds of $200, $500, and $1000 John = Customer("John", 200) Sally = Customer("Sally", 500) Rich = Customer ("Rich", 1000) customers = [John, Sally, Rich] # Print each customer with bicycle sale sheet from bike shop making sure customer can afford at least one bicycle for customer in customers: print "{} Current Inventory for {}".format(CycleWorld.shop_name,customer.customer_name) CycleWorld.print_inventory(customer.bike_purchase_fund) print "" # Print the bike shop's initial inventory print "{} Total Starting Inventory".format(CycleWorld.shop_name) CycleWorld.print_inventory() print "" # Each customer purchases a bicycle - print bicycle purchased, cost, and remaining purchase fund CycleWorld.reset_profit_balance() bicycle_purchases = {John: Huffy, Sally: Diamondback, Rich: Windsor} print "Bicycle Purchases" for customer in bicycle_purchases: bicycle_sold = bicycle_purchases[customer] customer.purchase_bicycle(bicycle_sold, CycleWorld.bicycle_sales_price(bicycle_sold)) CycleWorld.sell_bicycle(bicycle_sold)
if __name__ == "__main__": bike_1 = Bicycle('Schwinn', 'Protocol 1.0', '41 lbs.', 320.0) bike_2 = Bicycle('Schwinn', 'Ladies Perla', '42 lbs.', 160.0) bike_3 = Bicycle('Columbia', 'Palmetto', '38 lbs.', 140.0) bike_4 = Bicycle('Cyrusher', 'XC700', '32 lbs.', 680.0) bike_5 = Bicycle('Fito', 'Marina', '33 lbs.', 200.0) bike_6 = Bicycle('Huffy', 'Fresno', '42 lbs.', 190.0) person_1 = Customer('Jhon Doe', 200.00) person_2 = Customer('Gemma Cain', 500.00) person_3 = Customer('Marco Reus', 1000.00) shop_inventory = { 'Protocol 1.0': (bike_1, 5), 'Ladies Perla': (bike_2, 5), 'Palmentto': (bike_3, 5), 'XC700': (bike_4, 5), 'Marina': (bike_5, 5), 'Fresno': (bike_6, 5) } shop = BikeShop('Cycles', shop_inventory) person_1.affordable_bikes(shop) person_2.affordable_bikes(shop) person_3.affordable_bikes(shop) shop.print_inventory() person_1.buy('Palmentto', shop) person_2.buy('Protocol 1.0', shop) person_3.buy('XC700', shop) shop.print_inventory()
hybrid = Bicycle("hybrid", medium, steel)#, 30, 250) firstprod = [road, mountain, hybrid] #cruiser = Bicycle("cruiser", large, steel)#, 60, 200) #bmx = Bicycle("bmx", small, aluminum)#, 55, 300) #tandem = Bicycle("tandem", large, aluminum)#, 75, 600) #secondprod= [cruiser, bmx, tandem] #create 2 suppliers bob = BicycleManufacturer("bob", firstprod, 10) bob.print_inventory() #Tom = BicycleManufacturer("Tom", supply2, 10) # create a bike shop mellow = BikeShop("mellow", 20, bob) mellow.print_inventory() # This is due to weird floating point differences. Better solution # is to use something like numpy's assert_allclose. For now this works. # create 3 customers han = Customer("Han", 300) luke = Customer("Luke", 500) leia = Customer("Leia", 1000) customers = [han, luke, leia] print('<== bikes affordable for each customer ==>') for customer in customers: customer.print_affordable_bikes(mellow) print('<== each customer purchases a bike ==>') han.purchase_bike(mountain, mellow)