Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Data:
- def __init__(self, z, l, a):
- self.zi = z #proprietate
- self.luna = l
- self.an = a
- def __repr__(self):
- return "(" + str(self.zi) + ", " + str(self.luna) + ", " + str(self.an) + ")"
- def __eq__(self, bunica):
- c1 = self.zi == bunica.zi # este o conditie: true sau false
- c2 = self.luna == bunica.luna # tot conditie
- c3 = self.an == bunica.an # conditie
- return c1 and c2 and c3
- def __lt__(self, scufita):
- # __lt__ = less than
- # __gt__ = greated than
- # __le__ = less than and equal
- # __ge__ = greated then and equal
- # facem sortarea datelor prin verificare de conditii
- # intai incepem cu anul, apoi luna, apoi ziua
- if self.an < scufita.an:
- return True
- elif self.an > scufita.an:
- return False
- elif self.luna < scufita.luna:
- return True
- elif self.luna > scufita.luna:
- return False
- elif self.zi < scufita.zi:
- return True
- elif self.zi > scufita.zi:
- return False
- else:
- return False
- def __sub__(self, lupu):
- q1 = (self.an - 1) * 365 + (self.luna - 1) * 30 + self.zi
- q2 = (lupu.an - 1) * 365 + (lupu.luna - 1) * 30 + lupu.zi
- dif = abs(q1 - q2)
- ani = int(dif // 365)
- luni = int((dif % 365) // 30)
- zile = int(dif % 365 % 30)
- vanatorul = Data(zile, luni, ani)
- return vanatorul
- class Locatie:
- def __init__(self, x, y):
- self.__x = x
- self.__y = y
- def __repr__(self):
- print("X: ", self.__x)
- print("Y: ", self.__y)
- def setLocatie(self, x, y):
- self.__x = x
- self.__y = y
- def getLocatieX(self):
- return self.__x
- def getLocatieY(self):
- return self.__y
- class ObiectivTuristic:
- def __init__(self, nume, locatie, pret=10):
- #self.__anInfiintare = 1900
- self.numeObiectiv = nume
- self.locatieObiectiv = locatie
- self.pretLocatie = pret
- def __new__(cls):
- an = int(input("Introduceti anul: "))
- nume = str(input("Introduceti numele: "))
- x = int(input("Introduceti locatie x: "))
- y = int(input("Introduceti locatie y: "))
- pret = int(input("Introduceti pretul: "))
- obiect = super().__new__(cls)
- #obiect = cls.__init__(nume, Locatie(x,y), pret)
- obiect.anInfiintare = an
- obiect.numeObiectiv = nume
- obiect.locatieObiectiv = Locatie(x, y)
- obiect.pretLocatie = pret
- return obiect
- def __repr__(self):
- return "An infiintare: " #+ self.__anInfiintare
- def setAnInfiintare(self, an):
- #self.__anInfiintare = an
- pass
- def setNumeObiectiv(self, nume):
- self.numeObiectiv = nume
- def setLocatieObiectiv(self, locatie):
- self.locatieObiectiv = locatie
- def setPretIntrare(self, pret):
- self.pretLocatie = pret
- def getAnInfiintare(self):
- pass
- #return self.anInfiintare
- def getNumeObiectiv(self):
- return self.numeObiectiv
- def getLocatieObiectiv(self):
- return self.locatieObiectiv
- def getPretIntrare(self):
- return self.pretLocatie
- class TraseuTuristic:
- def __init__(self, dataInceput, dataEnd, combustibil):
- self.__obiectiv = []
- self.__dataInceput = dataInceput
- self.__dataEnd = dataEnd
- self.__combustibil = combustibil
- def __repr__(self):
- for i in len(self.__obiectiv):
- print("Obiectiv: ", self.__obiectiv[i])
- print("-------------")
- locatie1 = Locatie(122, 15)
- locatiePrislop = Locatie(5,5)
- locatieArsenieBoca = Locatie(40, 40)
- #obiectiv1 = ObiectivTuristic( "Eiffel", locatie1)
- #obiectiv2 = ObiectivTuristic( "Parlament", locatiePrislop, 15)
- obiectiv3 = ObiectivTuristic()
- #print(obiectiv1)
- #print(obiectiv2)
- print(obiectiv3)
- #a = obiectiv3.getAnInfiintare()
- #print(int(a))
Add Comment
Please, Sign In to add comment