Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Locomotiva:
- def __init__ (self,p):
- #constructorul locomotivei
- #self este nr sub care a fost inregistrata locomotiva in memoria ram
- self.putereLocomotiva = p
- def __repr__(self):
- return "Locmotiva de putere {}".format(self.putereLocomotiva)
- locomotivaluiRadu = Locomotiva (323)
- x = 3
- print (locomotivaluiRadu)
- print (x)
- class VagonCalatori:
- def __init__(self,nrMaxp,nrEfp):
- self.nrMaximPasageri = nrMaxp
- self.nrEfectivPasageri = nrEfp
- #atribute(nrMaximPasageri si NrEfecticPasageri)
- #parametri(neMaxp si nrEfp)
- def __repr__(self):
- return "Vagon calatori {}/ {} pasageri.".format(self.nrMaximPasageri ,self.nrEfectivPasageri)
- def greutateVagon(self):
- masaPopulatie = 80 * self.nrEfectivPasageri
- masaTotala = 55 + masaPopulatie/1000
- #masaPopulatie si masaTotala sunt variabile locale
- return masaTotala
- def venit(self, distanta):
- incasareCalatori = 50 * self.nrEfectivPasageri
- incasareTotala = (incasareCalatori * distanta) / 100
- return incasareTotala
- VagonBianca = VagonCalatori (80, 23)
- VagonAndrei = VagonCalatori (80, 45)
- class VagonMarfa:
- def __init__ (self, tMax, vMax, Tip):
- self.tonajEfectiv = tMax
- self.volumMaxim = vMax
- self.tip = Tip
- def __repr__(self):
- return "Vagon marfa {} / {} tonaj, volum.".format(self.tonajEfectiv, self.volumMaxim)
- def greutate(self):
- return 55 + self.tonajEfectiv
- print (VagonBianca)
- print (VagonAndrei)
- print (VagonAndrei.greutateVagon())
- #prin greutate apelez functia de greutate asupra obiectului vagonAndrei
- #la apelarea unei functii NU se pune SELF
- print (VagonBianca.venit(480))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement