Skip to content

Instantly share code, notes, and snippets.

@odubno
Last active August 29, 2015 14:05
Show Gist options
  • Save odubno/b0a63e88260abae702d9 to your computer and use it in GitHub Desktop.
Save odubno/b0a63e88260abae702d9 to your computer and use it in GitHub Desktop.
Bicycle Industry Draft 1
class Wheels():
def __init__(self, name, weight, cost):
self.name = name
self.weight = weight
self.cost = cost
class Frames():
def __init__(self, composition, weight, cost):
self.composition = composition
self.weight = weight
self.cost = cost
def __repr__(self):
return 'This is {} {} {}'.format(self.composition, self.weight, self.cost)
class BicycleModels(Wheels, Frames):
def __init__(self, name, manufacturer, wheel, frame):
self.name = name
self.manufacturer = manufacturer
self.weight = 2 * wheel.weight + frame.weight
self.cost = 2 * wheel.cost + frame.cost
def __repr__(self):
return "This is {} by {} with {} wheels and {} frame".format(self.name, self.manufacturer, self.wheel, self.frame)
class Bicycle_Manufacturer():
def __init__(self, name, models, percentage):
self.name = name
self.models = models
self.percentage = percentage
class Bike_Shop():
def __init__(self, name, manufacturers, margin):
self.name = name
self.margin = margin
self.profit = 0
models = []
for manufacturer in manufacturers:
for model in manufacturer.models:
models.append(model)
cost.append((model, (1+manufacturer.percentage)*model.cost))
self.costs = dict(costs)
self.inventory = dict()
for model in models:
self.inventory[model] = 0
def buy_model(self, model, amount = 1):
self.inventory[model] += amount
def sell_model(self, model, amount = 1):
self.inventory[model] -= amount
self.profit += self.margin * self.costs(model)
class Customer():
def __init__(self, name, funds):
self.name = name
self.funds = funds
self.bicycle = []
def buy_bicycle(self, bike, cost):
if cost > self.funds:
print "Not enough money."
else:
self.funds -= cost
self.bicycle.append(bike)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment