Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from enum import Enum
- class Combustibil(Enum):
- BENZINA=1
- MOTORINA=2
- GPL=3
- ELECTRIC=4
- class Masina (object):
- def __init__(self,nr,c):
- self.__nrInmatriculare=nr
- self.__combustibil=c
- self.__link= None
- def getnrInamtriculare(self):
- return self.__nrInmatriculare
- def getCombustibil(self):
- return self.__combustibil
- def getLink(self):
- return self.__link
- def setnrInamtriculare(self,newNr):
- self.__nrInmatriculare=newNr
- def setLink(self,newLink):
- self.__link=newLink
- def __repr__(self):
- return " Nr Inmatriculare :{} combustibil :{}".format(self.__nrInmatriculare,self.__combustibil)
- m1=Masina("TM11ABC",Combustibil.BENZINA)
- m2=Masina("SV22AAA",Combustibil.GPL)
- print(m1)
- print(m2)
- class Lista:
- def __init__(self):
- self.__radacina=None
- def adauga(self,masina):
- if self.__radacina==None:
- self.__radacina=masina
- else:
- masina.setLink(self.__radacina)
- self.__radacina=masina
- def __repr__(self):
- x=self.__radacina
- while x!=None:
- s=" "
- s=s+str(x)
- x=x.getLink()
- return x
- l=Lista()
- l.adauga(m1)
- l.adauga(m2)
- print(l)
- l.cautare(m1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement