Advertisement
Guest User

Untitled

a guest
Apr 17th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 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.  
  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(userList):
  36. printList(userList)
  37. number = int(input("Prosze wpisac numer pojazdu, który mam usunac"))-1
  38. try:
  39. userList.pop(number)
  40. except IndexError:
  41. print("Nie ma pojazdu o takim numerze na liscie")
  42. return userList
  43.  
  44.  
  45. def printData(userList):
  46. printList(userList)
  47. number = int(input("Prosze wpisac numer pojazdu, który mam wypisać"))
  48. try:
  49. print(userList[number-1].nazwa, " ",userList[number-1].predkosc)
  50. except IndexError:
  51. print("Prowadzono nie poprawny numer pojazdu")
  52. def printList(userList):
  53. counter = 1
  54. for i in userList:
  55. print(counter, " ", i.nazwa)
  56. counter+=1
  57.  
  58. pojazdy = []
  59.  
  60. while 1!=0:
  61. print("Proszę wprowadzić cyfrę: ")
  62. print("1 by wprowadzić nowy pojazd")
  63. print("2 by usunąć wybrany pojazd")
  64. print("3 by wyświetlić dane o wybranym pojeździe")
  65. print("4 by opuścić program")
  66. choice= input()
  67. if choice=='1':
  68. pojazdy.append(addVehicle())
  69. if choice =='2':
  70. pojazdy=deleteVehicle(pojazdy)
  71. if choice =='3':
  72. printData(pojazdy)
  73. if choice=='4':
  74. print("Dziękuje za korzystanie z programu")
  75. raise SystemExit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement