Guest User

Untitled

a guest
Apr 17th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. class Pojazd:
  2. def __init__(self, nazwa, predkosc):
  3. self.nazwa=nazwa
  4. self.predkosc = predkosc
  5.  
  6. class Osobowy(Pojazd):
  7. pass
  8.  
  9. #self.drzwi, self.silnik = input("Proszę podać ilu drzwiowy jest pojazd oraz rodzaj silnika")
  10.  
  11. class Motor(Pojazd):
  12. pass
  13.  
  14. class Dostawczy(Pojazd):
  15. pass
  16.  
  17.  
  18. def addVehicle():
  19. while 1!=0:
  20. print("Proszę wpisać cyfrę: ")
  21. print("1 by dodać samochod osobowy")
  22. print("2 by dodać motor")
  23. print("3 by dodać samochód dostawczy")
  24. userChoice=input()
  25. print("Proszę wprowadzić nazwe i predkosc pojazdu")
  26. name, speed = input().split()
  27. if userChoice =='1':
  28. return Osobowy(name,speed)
  29. if userChoice =='2':
  30. return Motor(name,speed)
  31. if userChoice =='3':
  32. return Dostawczy(name,speed)
  33.  
  34.  
  35. def deleteVehicle():
  36. print("goodby")
  37.  
  38. def printData(userList):
  39. printList(userList)
  40. number = int(input("Prosze wpisac numer pojazdu, który mam wypisać"))
  41. try:
  42. print(userList[number-1].nazwa, " ",userList[number-1].predkosc)
  43. except ValueError:
  44. print("Prowadzono nie poprawny numer pojazdu")
  45. def printList(userList):
  46. counter = 1
  47. for i in userList:
  48. print(counter, " ", i.nazwa)
  49. counter+=1
  50.  
  51. pojazdy = []
  52.  
  53. while 1!=0:
  54. print("Proszę wprowadzić cyfrę: ")
  55. print("1 by wprowadzić nowy pojazd")
  56. print("2 by usunąć wybrany pojazd")
  57. print("3 by wyświetlić dane o wybranym pojeździe")
  58. print("4 by opuścić program")
  59. choice= input()
  60. if choice=='1':
  61. pojazdy.append(addVehicle())
  62. if choice =='2':
  63. deleteVehicle()
  64. if choice =='3':
  65. printData(pojazdy)
  66. if choice=='4':
  67. print("Dziękuje za korzystanie z programu")
  68. raise SystemExit
Advertisement
Add Comment
Please, Sign In to add comment