Пример #1
0
def main():
    print_header()
    # Create 6 different bicycle models
    bike0 = Bicycle("Trek FUEL EX 9.7 29", 25, 800)
    bike1 = Bicycle("Specialized PITCH COMP 650B", 30, 300)
    bike2 = Bicycle("Trek MARLIN 4", 45, 150)
    bike3 = Bicycle("Specialized REMEDY", 30, 600)
    bike4 = Bicycle("Specialized CYCLONE", 50, 75)
    bike5 = Bicycle("Trek TISKER", 45, 100)
    print()

    # Create bicycle shop
    bss = BikeShop("Bicycle Sports Shop")
    print()
    # Stock the shop with the bicycles. The shop should charge
    # its customers 20% over the cost of the bikes.
    bikes = [bike0, bike1, bike2, bike3, bike4, bike5]
    for bike in bikes:
        bss.stock(bike, 5, 0.2)  # 5 bikes of one model added to shop's stock
    print()

    # Create three customers. One customer has a budget of $200,
    # the second $500, and the third $1000.
    customer1 = Customer("Joe", 200)
    customer2 = Customer("Jen", 500)
    customer3 = Customer("Jerry", 1000)

    # Print the name of each customer, and a list of the bikes offered
    # by the bike shop that they can afford given their budget.
    # Make sure you price the bikes in such a way that each customer
    # can afford at least one.
    customers = [customer1, customer2, customer3]
    customer_rec_bikes = {}  # create dict for rec bikes/customer
    for customer in customers:
        #print(customer.name)
        recommended_bikes = recommend_bikes(customer, bss)
        recommended_models = [bike["model"] for bike in recommended_bikes]
        recommended_models = set(recommended_models)
        customer_rec_bikes[customer.name] = recommended_bikes
        print("Recommended bikes for {}".format(customer.name))
        for bike in recommended_models:
            print(bike)
        print()

    # Print the initial inventory of the bike shop for each bike it carries.
    # print("Initial inventory of {}:".format(bss.name))
    print("{}'s initial inventory:".format(bss.name))
    for key, value in bss.count().items():
        print("{}: {} available".format(key, value))
    print()

    # Have each of the three customers purchase a bike then print
    # the name of the bike the customer purchased, the cost,
    # and how much money they have left over in their bicycle fund.
    for customer in customers:
        bike_choice = random.choice(customer_rec_bikes[customer.name])
        print("{}'s choice: {}".format(customer.name, bike_choice["model"]))
        bike = Bicycle(model=bike_choice["model"],
                       weight=bike_choice["weight"],
                       cost=bike_choice["cost"])
        customer.buy(1, bike, bss)
        print()

    # After each customer has purchased their bike, the script should
    # print out the bicycle shop's remaining inventory for each bike,
    # and how much profit they have made selling the three bikes.
    print("{}'s inventory after sale:".format(bss.name))
    for key, value in bss.count().items():
        print("{}: {} available".format(key, value))
    print()
    print("{}'s profit after today's sale:\n${:.2f}".format(
        bss.name, bss.profit))
Пример #2
0
import random
from bicycles import Bicycle, BikeShop, Customer

# Create a list of Bikes, then create a BikeShop, stock it
# with Bikes...

bikes = [
    Bicycle("Desert Cruiser", 35, 1500), Bicycle("Rock Climber", 25, 3800),
    Bicycle("Speed Racer", 15, 10000), Bicycle("The Aspen", 20, 8500),
    Bicycle("City Ride", 40, 855), Bicycle("Low Rider", 50, 5550)
    ]

shop = BikeShop("Bill's Bikes", 20, bikes)

# Create a list of Customers, then iterate over them, print
# the Customer's name and Bikes they can afford to buy...

customers = [Customer("Joe", 6000), Customer("Tom", 8000), Customer("Jim", 15000)]

for customer in customers:

    bikes = ", ".join( bike.model for bike in shop.filter(customer.fund) )
    print (customer.name, "|", bikes)

# Print BikeShop before making sales...

print (shop)

# Iterate over the customers, sell each a Bike, then list customer,
# what they bought, the cost, and how much $ they have left...
Пример #3
0
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()
Пример #4
0
from bicycles import Bicycle
from bicycles import Wheel
from bicycles import Frame
from bicycles import BikeShop
from bicycles import Customer
        
if __name__ == '__main__':
    Wheelies = BikeShop("Wheelies")
    
    wheel1 = Wheel("brand1", 12, 20, "BMX")
    wheel2 = Wheel("brand2", 18, 100, "Mountain")
    wheel3 = Wheel("brand3", 24, 250, "Racing")
    
    frame1 = Frame("Aluminum", 34, 45)
    frame2 = Frame("Carbon", 41, 250)
    frame3 = Frame("Steel", 50, 345)
    
    
    Merida = Bicycle("Merida", wheel1, wheel1, frame1)
    Trek = Bicycle("Trek", wheel1, wheel1, frame2)
    Cannondale = Bicycle("Cannondale", wheel2, wheel2, frame1)
    Kona = Bicycle("Kona", wheel2, wheel2, frame3)
    Scott = Bicycle("Scott", wheel3, wheel3, frame1)
    Marin = Bicycle("Marin", wheel3, wheel3, frame2)
    
    Wheelies.add_bike(Merida, 12)
    Wheelies.add_bike(Trek, 15)
    Wheelies.add_bike(Cannondale, 20)
    Wheelies.add_bike(Kona, 25)
    Wheelies.add_bike(Scott, 18)
    Wheelies.add_bike(Marin,10)
Пример #5
0
    #Create a bicycle shop that has 6 different bicycle models in stock. The shop should charge its customers 20% over the cost of the bikes.
    
    bikes = {
        Bicycle("cheetahbike", 10, 50), Bicycle("catbike", 25, 100),
        Bicycle("dogbike", 50, 200), Bicycle("turtlebike", 75, 300),
        Bicycle("birdbike", 100, 500), Bicycle("capybike", 200, 1000)
    }
    customers = [Customers('jim', 200), Customers('oscar', 500), Customers('jan', 1000)]

    jim = Customers('jim', 200)
    oscar = Customers('oscar', 500)
    jan = Customers('jan', 1000)
    
    #instantiate the bike shop and add bikes to inventory dictionary {model: object}
    theoffice =  BikeShop('theoffice', bikes)
    
#Print the name of each customer, and a list of the bikes offered by the bike shop that they can afford given their budget. Make sure you price the bikes in such a way that each customer can afford at least one.
    for customer in customers:
        customer.affordables = theoffice.filter(customer.fund)
        print ("{0} can afford: ".format(customer.name) + ", ".join(bike.model for bike in customer.affordables))

    #Print the initial inventory of the bike shop for each bike it carries.
    print ("\n"+ "Here's what the office has to offer today:")
    print (key for key, value in theoffice.inventory.items())
    #     print (key)
    # print()
    
    print (theoffice.inventory.keys())
    print (theoffice.inventory.values())
    
Пример #6
0
"""Import classes and lists from Bicycles.py. Create bike instances, bike shop instance, and customer instances."""

from bicycles import Bicycle, BikeShop, Customer, inventory, demand_curve

if __name__=="__main__":

    bike1 = Bicycle(inventory[0][0], inventory[0][1], inventory[0][2])
    bike2 = Bicycle(inventory[1][0], inventory[1][1], inventory[1][2])
    bike3 = Bicycle(inventory[2][0], inventory[2][1], inventory[2][2])
    bike4 = Bicycle(inventory[3][0], inventory[3][1], inventory[3][2])
    bike5 = Bicycle(inventory[4][0], inventory[4][1], inventory[4][2])
    bike6 = Bicycle(inventory[5][0], inventory[5][1], inventory[5][2])

    bikes = [bike1, bike2, bike3, bike4, bike5, bike6]

    shop_instance = BikeShop("Dave's World of Bikes", 0.20)

    customer1 = Customer(demand_curve[0][0], demand_curve[0][1])
    customer2 = Customer(demand_curve[1][0], demand_curve[1][1])
    customer3 = Customer(demand_curve[2][0], demand_curve[2][1])

    customers = [customer1, customer2, customer3]

    for customer in customers:
        print("\nCustomer Name: %s\nCustomer Budget: %d\n" % (customer.customer_name, customer.budget))
        for bike in bikes:
            if bike.cost * (1 + shop_instance.margin) <= customer.budget:
                print("Bike Model: %s, Price: %d" % (bike.model, bike.cost * (1 + shop_instance.margin)))

    print("\nInitial Inventory: ")
    for x in range(0,6):
Пример #7
0
import random
from bicycles import Bicycle, BikeShop, Customer

# First create a list of Bikes, then create a BikeShop, stocking it
# with the Bikes...

bikes = [
    Bicycle("Rock Hopper", 75, 100), Bicycle("Dirt Jumper", 70, 150),
    Bicycle("Speed Demon", 50, 250), Bicycle("Mountaineer", 90, 350),
    Bicycle("Road Master", 65, 100), Bicycle("Ghetto King", 75, 550)
    ]

shop = BikeShop("Surplus Cycles", 20, bikes)

# Now, create a list of Customers, then iterate over them, printing
# the Customer's name and the Bikes that they can afford...

customers = [Customer("Ali", 200), Customer("Bob", 500), Customer("Caz", 1000)]

for customer in customers:

    bikes = ", ".join( bike.model for bike in shop.filter(customer.fund) )
    print customer.name, "|", bikes

# Print the BikeShop before making any sales...

print shop

# Iterate over the customers, selling each a Bike, then using a template,
# print who the customer is, what they bought, what it cost, and how much
# they have left over...
Пример #8
0
# Define 3 frame types
Aluminum = Frame("Aluminum", 10, 150)
Carbon = Frame("Carbon", 4, 275)
Steel = Frame("Steel", 15, 75)

# Define 6 bicycle models
Schwinn = Bicycle("Schwinn", Avenir, Aluminum)
Huffy = Bicycle("Huffy", Avenir, Steel)
Vilano = Bicycle("Vilano", StaTru, Carbon)
Diamondback = Bicycle("Diamondback", StaTru, Aluminum)
Kestrel = Bicycle("Kestrel", Aeromax, Carbon)
Windsor = Bicycle("Windsor", Aeromax, Aluminum)

# 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 ""
Пример #9
0
#print bike1.cost()

#Add bikes to Manufacturers inventory
manuf1.catalog.append(bike1)
manuf1.catalog.append(bike2)
manuf1.catalog.append(bike3)
#return the cost of a bike
#print Manuf1.catalog[0].model

# Create 3 customers
cust1 = Customer("Larry", "200", None)
cust2 = Customer("Moe", "500", None)
cust3 = Customer("Curly", "1000", None)

#Create a Bicycle Shop + buy 6 bicycles
store101 = BikeShop("Mike's Bikes", None, .20)
store101.add_inventory(manuf1.catalog[0], manuf1.catalog[1], manuf1.catalog[2])
print "wholesale value of invenory:", store101.inventory_wholesale()
print "retail value of invenory:", store101.inventory_retail()
print "potential profit", store101.potential_profit()


#Print the name of each customer, and a list of the bikes offered by the bike shop that they can afford given their budget.
def evaluate_budget(customer_list, storename):
    customer_list = []
    customer_list[0].append(Cust1)

    for customer in customer_list:
        i = 0
        item_price = 0
        print "The budget of %s is %d" % (customer.name, int(customer.budget))
Пример #10
0
from bicycles import BikeShop
from bicycles import Customer


if __name__ == '__main__': 

#Creates a bike shop with 6 bicycle models and charges bikes at 20% over its cost.
    b1 = Bicycle("Aero", 20, 100)
    b2 = Bicycle("TCR Advanced", 20, 380)
    b3 = Bicycle("Trinity", 20, 600)
    b4 = Bicycle("Defy", 20, 130)
    b5 = Bicycle("Contend", 20, 400)
    b6 = Bicycle("Escape", 20, 800)
    
    
    bikeshop = BikeShop("Spencer's Bike Mart",  0)
    bikeshop.inventory.extend((b1,b2,b3,b4,b5,b6))
    
#Creates three customers with $200, $500, and $1000 respectively.
    p1 = Customer("Bob", 200)
    p2 = Customer("Steve", 500)
    p3= Customer("John", 1000)

    customers = [p1, p2, p3]
    
    
#Prints the name of each customer and the bikes each person can afford. 
    
    for x in customers:
        print("\nPossible bikes for " + x.name + ":\n") 
        for y in bikeshop.inventory:
Пример #11
0
  """ Create frames """
  frame1 = Frame("Aluminum", 12, 500)
  frame2 = Frame("Carbon", 8, 750)
  frame3 = Frame("Steel", 15, 400)
  
  """ Create 6 different bicycle models """
  first_bike = Bicycle("Road", wheel3, frame1)
  second_bike = Bicycle("Mountain", wheel2, frame3)
  third_bike = Bicycle("Touring", wheel3, frame1)
  fourth_bike = Bicycle("Hybrid", wheel2, frame3)
  fifth_bike = Bicycle("Triathlon", wheel1, frame2)
  sixth_bike = Bicycle("Track", wheel1, frame2)

  """ Create a bicycle shop that has 6 different bicycle models in stock """
  inventory_list = [ first_bike, second_bike, third_bike, fourth_bike, fifth_bike, sixth_bike ]
  bike_shop = BikeShop("Ryan's Shop", 20, inventory_list)
  
  """ 
    Print the initial inventory of the bike shop for each bike it carries.
  """
  print bike_shop
    
  """ Create three customers """
  customer_list = [ Customer("Ryan", 2000), Customer("Audrey", 3500), Customer("Amy", 4500) ]
  
  """ 
  Print the name of each customer
  """
  print "\nCustomers"
  print "-" * 20
Пример #12
0
from bicycles import Bicycle
from bicycles import BikeShop
from bicycles import Customer

if __name__ == '__main__':

    #Creates a bike shop with 6 bicycle models and charges bikes at 20% over its cost.
    b1 = Bicycle("Aero", 20, 100)
    b2 = Bicycle("TCR Advanced", 20, 380)
    b3 = Bicycle("Trinity", 20, 600)
    b4 = Bicycle("Defy", 20, 130)
    b5 = Bicycle("Contend", 20, 400)
    b6 = Bicycle("Escape", 20, 800)

    bikeshop = BikeShop("Spencer's Bike Mart", 0)
    bikeshop.inventory.extend((b1, b2, b3, b4, b5, b6))

    #Creates three customers with $200, $500, and $1000 respectively.
    p1 = Customer("Bob", 200)
    p2 = Customer("Steve", 500)
    p3 = Customer("John", 1000)

    customers = [p1, p2, p3]

    #Prints the name of each customer and the bikes each person can afford.

    for x in customers:
        print("\nPossible bikes for " + x.name + ":\n")
        for y in bikeshop.inventory:
            if (y.cost * 1.2) <= x.fund:
Пример #13
0
from bicycles import Bicycle, BikeShop, Customer, Frame, Wheel, Manufacturer
from random import randint


def list_inventory(shop):
    for bike in shop.inventory:
        print "{}: {} (${:,.2f})".format(bike.model_name, shop.inventory[bike],
                                         shop.price[bike])


if __name__ == '__main__':
    # Set up the bike shop.  Stock 6 models, and surcharge 20%.
    shop = BikeShop("LoPresti's Bike Shop", 0.20)
    print 'Welcome to {}...\n'.format(shop.shop_name)

    # Define bike manufacturers.  Each to make three models of bike.
    # Each to apply a surcharge that is passed to the bike shop.
    jbc = Manufacturer("Johnstown Bike Company", 0.10)
    rbw = Manufacturer("Richland Bike Works", 0.15)

    # Define wheel types.
    jabba = Wheel("Jabba", 80, 37)  # obligatory Star Wars reference
    brock = Wheel("Brock", 55,
                  47)  # tough-as-nails hockey player for Johnstown Chiefs
    grady = Wheel("Grady", 40, 57)  # high-school friend

    # Define frame models.
    flyer = Frame("Flyer", "carbon", 15, 250)
    mondo = Frame("Mondo", "steel", 30, 390)
    reynolds = Frame("Reynolds", "aluminum", 20,
                     175)  # common brand of Al foil
Пример #14
0
    mountain = Bicycle("mountain", large, carbon)#, 55, 150)
    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 ==>')