Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import sys, os
  2.  
  3. # Moved the methods to the automobile from car
  4. class Automobile(object):
  5. def __init__(self, color):
  6. self.color = color
  7. self.model = "Honda"
  8.  
  9. # It honks!
  10. def honk(self):
  11. print "Bee Beep!"
  12.  
  13. # prints out the attributes and their number
  14. def description(self):
  15. print vars(self)
  16.  
  17. class Motorcycle(Automobile):
  18. def __init__(self, color):
  19. Automobile.__init__(self, color)
  20. self.wheelNum = 2
  21. self.make = "Ducati?"
  22. self.topSpeed = 70
  23.  
  24. class Car(Automobile):
  25. def __init__(self, color):
  26. Automobile.__init__(self, color)
  27. self.wheelNum = 4
  28. self.make = "Accord?"
  29. self.topSpeed = 100
  30.  
  31. class SemiTruck(Automobile):
  32. def __init__(self, color):
  33. Automobile.__init__(self, color)
  34. self.wheelNum = 16
  35. self.make = "Big Rig?"
  36. self.topSpeed = 60
  37.  
  38. #test stuff
  39. if __name__ == "__main__":
  40. test1 = Car("Red")
  41. print test1.color
  42. print test1.topSpeed
  43. test1.honk()
  44. test1.description()
  45.  
  46. test2 = Motorcycle("Green")
  47. print test2.color
  48. print test2.topSpeed
  49. test2.honk()
  50. test2.description()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement