Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Pojazd:
- def __init__(self, nazwa, predkosc):
- self.nazwa=nazwa
- self.predkosc = predkosc
- class Osobowy(Pojazd):
- pass
- class Motor(Pojazd):
- pass
- class Dostawczy(Pojazd):
- pass
- def addVehicle():
- while 1!=0:
- print("Proszę wpisać cyfrę: ")
- print("1 by dodać samochod osobowy")
- print("2 by dodać motor")
- print("3 by dodać samochód dostawczy")
- userChoice=input()
- print("Proszę wprowadzić nazwe i predkosc pojazdu")
- name, speed = input().split()
- if userChoice =='1':
- return Osobowy(name,speed)
- if userChoice =='2':
- return Motor(name,speed)
- if userChoice =='3':
- return Dostawczy(name,speed)
- def deleteVehicle(userList):
- printList(userList)
- number = int(input("Prosze wpisac numer pojazdu, który mam usunac"))-1
- try:
- userList.pop(number)
- except IndexError:
- print("Nie ma pojazdu o takim numerze na liscie")
- return userList
- def printData(userList):
- printList(userList)
- number = int(input("Prosze wpisac numer pojazdu, który mam wypisać"))
- try:
- print(userList[number-1].nazwa, " ",userList[number-1].predkosc)
- except IndexError:
- print("Prowadzono nie poprawny numer pojazdu")
- def printList(userList):
- counter = 1
- for i in userList:
- print(counter, " ", i.nazwa)
- counter+=1
- pojazdy = []
- while 1!=0:
- print("Proszę wprowadzić cyfrę: ")
- print("1 by wprowadzić nowy pojazd")
- print("2 by usunąć wybrany pojazd")
- print("3 by wyświetlić dane o wybranym pojeździe")
- print("4 by opuścić program")
- choice= input()
- if choice=='1':
- pojazdy.append(addVehicle())
- if choice =='2':
- pojazdy=deleteVehicle(pojazdy)
- if choice =='3':
- printData(pojazdy)
- if choice=='4':
- print("Dziękuje za korzystanie z programu")
- raise SystemExit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement