コード例 #1
0
def main():
    # Create an instance of bike shop - Frisco's Bike Mart

    FriscoBikeMart = Shop('Fisco Bike\'s Mart', .2)
    FriscoBikeMart.inventory = {
        'Madone': 5,
        'Lexa': 3,
        'Silque': 5,
        'FX': 2,
        'CrossRip': 1,
        'Tandem': 1
    }

    # Create 3 customers
    lee = Customer('Yih-Yoon Lee', 200)
    chia = Customer('Chang Chia', 500)
    joseph = Customer('Joseph Tan', 10000)

    customers = [lee, chia, joseph]

    madone = Bicycle('Madone', 150, 150)
    lexa = Bicycle('Lexa', 90, 400)
    silque = Bicycle('Silque', 80, 1000)
    fx = Bicycle('FX', 70, 1500)
    crossrip = Bicycle('CrossRip', 65, 4500)
    tandem = Bicycle('Tandem', 55, 8000)

    bicycles = [madone, lexa, silque, fx, crossrip, tandem]

    FriscoBikeMart.display_inventory()

    for customer in customers:
        customer.display_bikes(FriscoBikeMart, bicycles)

    for customer in customers:
        customer.buy_bike(customer, bicycles, FriscoBikeMart)

    print '\n{0}\'s Updated Inventory:'.format(FriscoBikeMart.shop_name)
    print '*' * 40

    FriscoBikeMart.display_inventory()

    print '\n{0}\'s total profit: {1}'.format(FriscoBikeMart.shop_name,
                                              FriscoBikeMart.total_profit)
コード例 #2
0
# 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...

template = "{0} bought the {1} at ${2}, and they have ${3} left over."
コード例 #3
0
ファイル: main.py プロジェクト: salonimrai/bicycles
from bicycles import Bicycle, BicycleShop, Customer

if __name__ == "__main__":
    print("Starting up...")

    bike1 = Bicycle("Red", 20, 100)
    bike2 = Bicycle("Blue", 20, 50)
    bike3 = Bicycle("Green", 20, 200)
    bike4 = Bicycle("Black", 20, 300)
    bike5 = Bicycle("Silver", 20, 100)
    bike6 = Bicycle("Purple", 20, 150)

    customer1 = Customer("Joe", 200)
    customer2 = Customer("Sally", 500)
    customer3 = Customer("Mike", 1000)

    shop1 = BicycleShop("Bike Shop", 0.2, 0)

    print(bike1)
    print(customer1)
    print(shop1)

    shop1.addBike(bike1)
    shop1.addBike(bike2)
    shop1.addBike(bike3)
    shop1.addBike(bike4)
    shop1.addBike(bike5)
    shop1.addBike(bike6)

    print(shop1)
    for i in shop1.inventory:
コード例 #4
0
ファイル: main.py プロジェクト: raghureddyram/bicycles
from bicycles import Bicycle, BicycleShop, Customer

if __name__ == '__main__':
    bike1 = Bicycle()
    huffy = Bicycle("Huffy", 30)
    speedster = Bicycle("Speedster", 5)
    shwin = Bicycle("Shwin", 20)

    bike1.cost()

    bills  = BicycleShop("Robert's Bikes", [bike1, huffy, speedster, shwin, huffy, bike1])

    print(bills.inventory_cost())
    print(bills.profit_or_loss())

    james = Customer("James", 200)
    edward = Customer("Eddy", 500)
    richie = Customer("Rich", 1000)

    customers = [james, edward, richie]

    print("-----------")
    customer_list = list(map((lambda customer: customer.name), customers)) ##is there a cleaner way to iterate and map over just the names?
    ## or customer_list = [customer.name for customer in customers]
    # print(customer_list)
    # print("customers are : {}".format(customer_list)
    bikes_in_customer_budget = {}

    for customer in customers:
        in_customer_budget = []
        for bike in bills.inventory:
コード例 #5
0
ファイル: main.py プロジェクト: AMontalva/bicycles
 hot_bicycles_manufacturers = Bicycle_Manufacturer("Hot Bicycles Manufacturer")
 hot_bicycles_manufacturers.build_bicycle(black_bicycle)
 hot_bicycles_manufacturers.build_bicycle(silver_bicycle)
 hot_bicycles_manufacturers.build_bicycle(gold_bicycle)
 
 bicycle_shop = Bicycle_Shop()
 bicycle_shop.buy_from_manufacturer(cool_bicycles_manufacturers, red_bicycle, 6)
 bicycle_shop.buy_from_manufacturer(cool_bicycles_manufacturers, blue_bicycle, 8)
 bicycle_shop.buy_from_manufacturer(cool_bicycles_manufacturers, green_bicycle, 4)
 bicycle_shop.buy_from_manufacturer(hot_bicycles_manufacturers, black_bicycle, 5)
 bicycle_shop.buy_from_manufacturer(hot_bicycles_manufacturers, silver_bicycle, 3)
 bicycle_shop.buy_from_manufacturer(hot_bicycles_manufacturers, gold_bicycle, 2)
 
 print("")
 
 fred = Customer("Fred", 200)
 martha = Customer("Martha", 500)
 jack = Customer("Jack", 1000)
 
 bicycle_shop.display_inventory()
 print("")
 bicycle_shop.see_profits()
 print("")
 
 bicycle_shop.display_within_customer_funds(fred)
 print("")
 fred.buy(bicycle_shop, red_bicycle)
 print("")
 bicycle_shop.display_inventory()
 print("")
 bicycle_shop.see_profits()
コード例 #6
0
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):
        print(inventory[x][0])
コード例 #7
0
import random
from bicycles import Bicycle, BikeShop, Customer

bikes = [
    Bicycle("Off-Road XC", 75, 100), Bicycle("Off-Road GRAVITY", 70, 150),
    Bicycle("Off-Road TRAIL", 50, 250), Bicycle("Off-Road SPRORT XC", 90, 350),
    Bicycle("Off-Road ENDURO", 65, 100), Bicycle("Off-Road RECREATION", 75, 550)
    ]

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

customers = [Customer("Hue", 200), Customer("Saigon", 500), Customer("Hanoi", 1000)]

print ("--------------------------Giant bikes Recommendation for Customer---------------------------------")
for customer in customers:

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

    print ("Customer:", customer.name, "|", bikes)

print ('\n\n', "--------------------------Surplus Before Sales---------------------------------")
print (shop)

print ("--------------------------Detail Sales---------------------------------")
template = "{0} bought the {1} at ${2}, and they have ${3} left over."

for customer in customers:
    
    affordables = shop.filter(customer.fund)
    shop.sell(random.choice(affordables), customer)
    
コード例 #8
0
    ems = Bicycle("Ems", flyer, grady, jbc)
    hambright = Bicycle("Hambright", mondo, jabba, rbw)
    renzi = Bicycle("Renzi", reynolds, jabba, rbw)
    chief = Bicycle("Chief", reynolds, brock, jbc)
    ram = Bicycle("Ram", mondo, grady, rbw)

    # Stock the bicycle shop. (0-3 facilitates testing of short-stock situations.)
    shop.stock_bike(kopriva, randint(0, 3))
    shop.stock_bike(ems, randint(0, 3))
    shop.stock_bike(hambright, randint(0, 3))
    shop.stock_bike(renzi, randint(0, 3))
    shop.stock_bike(chief, randint(0, 3))
    shop.stock_bike(ram, randint(0, 3))

    # Define customers. Three friends from high school.
    david = Customer("David", 200)
    doug = Customer("Doug", 500)
    bryan = Customer("Bryan", 1000)

    # Print the initial inventory of the bike shop for each bike it carries.
    print "\nOur current inventory (Bicycle: Number Available ($Price)):\n"
    list_inventory(shop)

    # 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.
    print "\nToday's customers (and their budgets) are:"
    for customer in [david, doug, bryan]:
        print "\n{} (${}) can afford:".format(customer.name, customer.fund)
        for bike in shop.inventory:
コード例 #9
0
ファイル: main.py プロジェクト: roadchimp/thinkful-pybicycle
bike5 = Bicycle("Diamondback Interval Carbon", frame2, wheel2)
bike6 = Bicycle("Diamondback Starlet", frame3, wheel3)

#print bike1.cost()
#bike1.wheel = wheel2
#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)
コード例 #10
0
# 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 ""

# Print the bike shop's initial inventory
print "{} Total Starting Inventory".format(CycleWorld.shop_name)
CycleWorld.print_inventory()
print ""
コード例 #11
0
ファイル: main.py プロジェクト: ncub8/bikeshop
from bicycles import Customer
from bicycles import Bicycle
from bicycles import Shop

if __name__ == '__main__':
  bikes = [{"bike":Bicycle("Schwimm",100,250),"number":2},
          {"bike":Bicycle("Valdemort",75,1800),"number":4},
          {"bike":Bicycle("Skipper",112,350),"number":8},
          {"bike":Bicycle("Zapp",80,1500),"number":3},
          {"bike":Bicycle("George",100,800),"number":2},
          {"bike":Bicycle("Crud",200,100),"number":17}]
  bikeshop = Shop("Big Bikes",bikes,0.20)
  
  customers = [Customer("Billy",2000),Customer("Sally",1000),Customer("Joey",750)]
  
  for customer in customers:
    print customer.name + " can afford these bikes:"
    bikechoices = bikeshop.canAfford(customer.fund)
    for bike in bikechoices:
      print(bike['bike'].name)
    print ""
    
  bikeshop.printInventory()
  print ""
    
  for customer in customers:
    customer.buyBike(bikeshop)
    
  bikeshop.printInventory()
  bikeshop.printProfit()
コード例 #12
0
ファイル: main.py プロジェクト: benrodrigue/bike_industry
# First create a list of Bikes, then create a BikeShop, stocking it
# with the Bikes...

bikes = [
    Bicycle("Super Speed", 75, 100), Bicycle("Mama Jama", 70, 150),
    Bicycle("Jumper Jack", 50, 250), Bicycle("Red Racer", 90, 350),
    Bicycle("Mud Muncher", 65, 100), Bicycle("Blastoff", 75, 550)
    ]

shop = BikeShop("Eddies Bike Shop", 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("Walter White", 200), Customer("Jesse Pinkman", 500), Customer("Hank Schrader", 1000)]

for customer in customers:

    bikes = ", ".join( bike.model for bike in shop.filter(customer.fund) )
    print(customer.name, "|", bikes) # should this be printing the customers name and fund??

# 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...

template = "{0} bought the {1} at ${2}, and they have ${3} left over."
コード例 #13
0
 
def make_inventory():
  inventory = {}
  for model in good_gears.models:
    inventory[model] = randint(0, 1)
  for model in best_bikes.models:
    inventory[model] = randint(0, 1)
  for model in sweet_spokes.models:
    inventory[model] = randint(0, 1)
  return inventory
    

hot_wheels = Bike_Shop("Hot Wheels", make_inventory(), .10, 0)

arlo = Customer("Arlo", 200, "none")
beatrice = Customer("Beatrice", 500, "none")
ida = Customer("Ida", 1000, "none")

print "Welcome to {}!!".format(hot_wheels.shop_name)
for key in hot_wheels.inventory:
  print "We have {} {} bikes in stock.  A {} costs ${}.".format((hot_wheels.inventory[key]),key.model_name, key.model_name, (key.cost + (key.cost * hot_wheels.margin)))
print "\n"
  
customer_list = [arlo, beatrice, ida]
#retail_price = (bike.cost + (bike.cost * shop.margin))

def can_afford(bike_list, shop, customer):
  affordable_bikes = []  
  for bike in bike_list:
    if (bike.cost + (bike.cost * shop.margin)) < customer.bike_funds:
コード例 #14
0
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:
                print(y.model)

#Prints initial inventory
    print("\nThese are all the bikes: \n")
コード例 #15
0
ファイル: main.py プロジェクト: davidyeungcoding/bicycles
from bicycles import Bicycle, Customer, BikeShop

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)
コード例 #16
0
bikes = [
    Bicycle("Huffy Sledgehammer", 25, 100),
    Bicycle("State Bicycle", 20, 200),
    Bicycle("Cinelli Gazzetta", 18, 500),
    Bicycle("All City Thunderdome", 15, 600),
    Bicycle("Bianchi Super Pista", 15, 800),
    Bicycle("Surly Steam Roller", 25, 400)
]
#shop name, 20% markup, list of bikes

shop = Bike_Shop("Fast Folks Cyclery", 20, bikes)

#customers name and budget
customers = [
    Customer("Mike", 200),
    Customer("Ryan", 500),
    Customer("Jon", 1000)
]

#prints customers as defined in __repr__ from bicycles.py
print(customers, "\n")

for customer in customers:
    #returns customers who can afford certain bikes within their budget
    bikes = ", ".join(bike.model_name
                      for bike in shop.can_afford(customer.budget))
    print(customer.name, "can afford the following bicycles:", bikes)

#The Bike Shop BEFORE sales with current inventory as defined in __repr__
print(shop)
コード例 #17
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))
コード例 #18
0
    #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)
    luke.purchase_bike(hybrid, mellow)
    leia.purchase_bike(road, mellow)
    mellow.print_inventory()