Created
August 7, 2015 22:35
-
-
Save s-ben/98b188be86e6e3b1d9dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bicycles | |
# Create bike shop with 6 bikes, 20% profit margin | |
print "Creating bike shop" | |
my_shop = bicycles.BikeShop('mikes', 6, 20) | |
model_list = bicycles.models.keys() | |
for i in range(0,my_shop.num_models): | |
my_shop_price = bicycles.models[model_list[i]][1] * (1+my_shop.margin) | |
my_shop.inventory[model_list[i]] = bicycles.Bicycle(my_shop_price,bicycles.models[model_list[i]][0],model_list[i]) | |
# Create three customers. One customer has a budget of $200, the second $500, and the third $1000. | |
customer_names = bicycles.customers.keys() | |
customer_list = [] | |
customer_list.append(bicycles.Customers(customer_names[0], 200)) | |
customer_list.append(bicycles.Customers(customer_names[1], 500)) | |
customer_list.append(bicycles.Customers(customer_names[2], 1000)) | |
print "Creating three customers" | |
# 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 customer_list: | |
print customer.name | |
print "has $" + str(customer.money) | |
print "can afford:" | |
for bike in my_shop.inventory: | |
if (customer.money >= my_shop.inventory[bike].price): | |
print bike + " $" + str(my_shop.inventory[bike].price) | |
# Print the initial inventory of the bike shop for each bike it carries. | |
print "Initial bike shop inventory:" | |
for bike in my_shop.inventory: | |
print bike | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment