Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. class Garaz:
  2. def __init__(self, nazwa):
  3. self.nazwa = nazwa
  4. self.miejsca = []
  5. def dodajPojazd(self, pojazd):
  6. self.miejsca.append(pojazd)
  7. def wyswieltPojazdy(self):
  8. napis = ""
  9. i = 0
  10. for p in self.miejsca:
  11. napis += str(i) + " "
  12. napis += p.wyswietlPojazd()
  13. napis += "\n"
  14. i += 1
  15. return napis
  16. def policzPojazdy(self):
  17. return len(self.miejsca)
  18. def sortuj(self):
  19. self.miejsca.sort()
  20.  
  21. class Pojazd:
  22. def __init__(self, marka, model, nrrej, silnik, pojemnosc, moc, czyLPG, przebieg):
  23. self.marka = marka
  24. self.model = model
  25. self.nrrej = nrrej
  26. self.silnik = silnik
  27. self.pojemnosc = pojemnosc
  28. self.moc = moc
  29. self.czyLPG = czyLPG
  30. self.przebieg = przebieg
  31. def wyswietlPojazd(self):
  32. return ("Pojazd: " + self.marka + " " + self.model)
  33. def __lt__(self, other):
  34. return self.nrrej < other.nrrej
  35.  
  36. g = Garaz("Pole przed stodołą")
  37. g.dodajPojazd(Pojazd("Nissan", "Skyline", "PO 78912", "benzyna V12 ", 8.2, 1200, True, 48322))
  38. g.dodajPojazd(Pojazd("Tesla", "3", "PO 12345", "elektryczny", 0, 200, False, 12144))
  39. g.dodajPojazd(Pojazd("Fiat", "Multipla", "PO MULTI", "diesel R4", 1.9, 105, False, 182433))
  40. g.dodajPojazd(Pojazd("UAZ", "452", "PO UAZIK", "benzyna R4", 2.4, 70, False, 430124))
  41. print(g.wyswieltPojazdy())
  42. print(g.policzPojazdy())
  43. print(g.sortuj())
  44. print(g.wyswieltPojazdy())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement