You are on page 1of 1

class RepositoryKException(Exception):

def __init__(self, *args):


pass

class RepositoryKey:
def __init__(self):
'''
Functie ce initializeaza sirul de chei.
Input:
-
Output:
-
'''
self.__key = []

def addNewBooking(self,k):
'''
Functie ce adauga o inchiriere cheie in sir.
Input:
-k, de tip key
Output:
-Eroare, daca exista.
'''
if k in self.__key:
raise RepositoryKException("Cheie existenta.")
self.__key.append(k)

def breakNewBooking(self,k):
'''
Functie ce returneaza un film, inchiriat de un client, in sir.
Input:
-k, de tip key
Output:
-Eroare, daca exista.
'''
if k in self.__key:
raise RepositoryKException("Cheie existenta.")
del_id = 0
i = 0
while i < len (self.__key):
if int(self.__key[i].getIdc()) == int(k.getIdc()) and
int(self.__key[i].getIdm()) == int(k.getIdm()):
del_id = i
i = i + 1
self.__key.remove(self.__key[del_id])

def getAllKeys(self):
'''
Functie ce returneaza toate cheile.
Input:
-
Output:
-sirul de chei.
'''
return self.__key[:]

You might also like