Advertisement
kevinbocky

cars1.py

Jan 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. class Cars():
  2.  
  3. def __init__(self, car_name):
  4. self.name = car_name
  5. self.description = None
  6. list = {}
  7.  
  8. def set_name(self, car_name):
  9. self.name = car_name
  10.  
  11. def set_description(self, car_description):
  12. self.description = car_description
  13.  
  14.  
  15. def get_description(self):
  16. return(self.description)
  17.  
  18. def describe(self):
  19. print(self.description)
  20.  
  21. def get_name(self):
  22. return (self.name)
  23.  
  24. def engine_types(self, engine_in_car):
  25. self.engine_type = engine_in_car
  26. print(self.name + " has a " + repr(self.engine_type))
  27.  
  28. def set_place(self, location):
  29. self.place = location
  30. return (self.place)
  31.  
  32.  
  33. def locate(self):
  34. print(self.name + " is " + self.place)
  35.  
  36. def move(self):
  37. print(self.name + " was " + self.place)
  38. newlocation = input(" where did you park the " + self.name + " ? ")
  39. self.place = newlocation
  40. print(self.name + " is " + self.place)
  41.  
  42.  
  43. ----------------
  44.  
  45.  
  46. from cars import Cars
  47.  
  48. hondacivic = Cars("Honda Civic")
  49. hondacivic.set_description("A fast little 4 cilinder with VTEC")
  50. hondacivic.engine_types("4 cilinder")
  51. hondacivic.set_place(" in the garage ")
  52.  
  53. hondacivic.describe()
  54.  
  55. mercedesgla = Cars("Mercedes GLA")
  56. mercedesgla.set_description("A super elegant cross between city and offroad")
  57. mercedesgla.engine_types("4 cilinder turbo")
  58. mercedesgla.set_place(" in the driveway ")
  59.  
  60.  
  61. mercedesgla.describe()
  62.  
  63.  
  64. hondacivic.locate()
  65. mercedesgla.locate()
  66.  
  67. while True:
  68. hondacivic.move()
  69. mercedesgla.move()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement