Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Thinkful Unit1 / Lesson3 / Project4: Bicycle.py
- # Bicycle Class:
- # Have a model name
- # Have a weight
- # Have a cost to produce
- class Bicycle(type):
- def __init__(self, name, weight, cost):
- self.name = name
- self.weight = weight
- self.cost = cost
- def model_name(self):
- return self.name
- def weight(self):
- return self.weight
- def cost(self):
- return self.cost
- # Bike Shops Class:
- # Have a name
- # Have an inventory of different bicycles
- # Sell bicycles with a margin over their cost
- # Can see how much profit they have made from selling bikes
- # Customers Class:
- # Have a name
- # Have a fund of money to buy a bike
- # Can buy and own a new bicycle
- def setParameters(type):
- if type == "street racer":
- name = "Zippidy Do"
- weight = 8
- cost = 950
- elif type == "mountain":
- name = "Regular Joe"
- weight = 11
- cost = 250
- elif type == "training":
- name = "First Try"
- weight = 10
- cost = 120
- elif type == "long haul":
- name = "Sore Rear"
- weight = 9.5
- cost = 680
- elif type == "professional":
- name = "The Lance"
- weight = 9
- cost = 5200
- elif type == "off road":
- name = "Down & Dirty"
- weight = 13
- cost = 475
- else:
- name = "unknown"
- weight = 0
- cost = 0
- return Bicycle(name, weight, cost)
- def main():
- setParameters("street racer")
- print(model_name())
- print(weight())
- print(cost())
- if __name__ == "__main__":
- main()
- """
- RESULTS:
- Traceback (most recent call last):
- File "bicycle.py", line 81, in <module>
- main()
- File "bicycle.py", line 74, in main
- setParameters("street racer")
- File "bicycle.py", line 69, in setParameters
- return Bicycle(name, weight, cost)
- TypeError: type() argument 2 must be tuple, not int
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement