Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. # Thinkful Unit1 / Lesson3 / Project4: Bicycle.py
  2.  
  3. # Bicycle Class:
  4. # Have a model name
  5. # Have a weight
  6. # Have a cost to produce
  7.  
  8. class Bicycle(type):
  9. def __init__(self, name, weight, cost):
  10. self.name = name
  11. self.weight = weight
  12. self.cost = cost
  13.  
  14. def model_name(self):
  15. return self.name
  16.  
  17. def weight(self):
  18. return self.weight
  19.  
  20. def cost(self):
  21. return self.cost
  22.  
  23.  
  24.  
  25. # Bike Shops Class:
  26. # Have a name
  27. # Have an inventory of different bicycles
  28. # Sell bicycles with a margin over their cost
  29. # Can see how much profit they have made from selling bikes
  30.  
  31.  
  32.  
  33.  
  34. # Customers Class:
  35. # Have a name
  36. # Have a fund of money to buy a bike
  37. # Can buy and own a new bicycle
  38.  
  39.  
  40. def setParameters(type):
  41. if type == "street racer":
  42. name = "Zippidy Do"
  43. weight = 8
  44. cost = 950
  45. elif type == "mountain":
  46. name = "Regular Joe"
  47. weight = 11
  48. cost = 250
  49. elif type == "training":
  50. name = "First Try"
  51. weight = 10
  52. cost = 120
  53. elif type == "long haul":
  54. name = "Sore Rear"
  55. weight = 9.5
  56. cost = 680
  57. elif type == "professional":
  58. name = "The Lance"
  59. weight = 9
  60. cost = 5200
  61. elif type == "off road":
  62. name = "Down & Dirty"
  63. weight = 13
  64. cost = 475
  65. else:
  66. name = "unknown"
  67. weight = 0
  68. cost = 0
  69. return Bicycle(name, weight, cost)
  70.  
  71.  
  72.  
  73. def main():
  74. setParameters("street racer")
  75.  
  76. print(model_name())
  77. print(weight())
  78. print(cost())
  79.  
  80. if __name__ == "__main__":
  81. main()
  82.  
  83.  
  84. """
  85. RESULTS:
  86. Traceback (most recent call last):
  87. File "bicycle.py", line 81, in <module>
  88. main()
  89. File "bicycle.py", line 74, in main
  90. setParameters("street racer")
  91. File "bicycle.py", line 69, in setParameters
  92. return Bicycle(name, weight, cost)
  93. TypeError: type() argument 2 must be tuple, not int
  94. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement