Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Garaz:
- def __init__(self, nazwa):
- self.nazwa = nazwa
- self.miejsca = []
- def dodajPojazd(self, pojazd):
- self.miejsca.append(pojazd)
- def wyswieltPojazdy(self):
- napis = ""
- i = 0
- for p in self.miejsca:
- napis += str(i) + " "
- napis += p.wyswietlPojazd()
- napis += "\n"
- i += 1
- return napis
- def policzPojazdy(self):
- return len(self.miejsca)
- def sortuj(self):
- self.miejsca.sort()
- class Pojazd:
- def __init__(self, marka, model, nrrej, silnik, pojemnosc, moc, czyLPG, przebieg):
- self.marka = marka
- self.model = model
- self.nrrej = nrrej
- self.silnik = silnik
- self.pojemnosc = pojemnosc
- self.moc = moc
- self.czyLPG = czyLPG
- self.przebieg = przebieg
- def wyswietlPojazd(self):
- return ("Pojazd: " + self.marka + " " + self.model)
- def __lt__(self, other):
- return self.nrrej < other.nrrej
- g = Garaz("Pole przed stodołą")
- g.dodajPojazd(Pojazd("Nissan", "Skyline", "PO 78912", "benzyna V12 ", 8.2, 1200, True, 48322))
- g.dodajPojazd(Pojazd("Tesla", "3", "PO 12345", "elektryczny", 0, 200, False, 12144))
- g.dodajPojazd(Pojazd("Fiat", "Multipla", "PO MULTI", "diesel R4", 1.9, 105, False, 182433))
- g.dodajPojazd(Pojazd("UAZ", "452", "PO UAZIK", "benzyna R4", 2.4, 70, False, 430124))
- print(g.wyswieltPojazdy())
- print(g.policzPojazdy())
- print(g.sortuj())
- print(g.wyswieltPojazdy())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement