You are on page 1of 2

class RepositoryCException(Exception):

def __init__(self, *args):


pass

class RepositoryClient:
def __init__(self):
'''
Functie ce initializeaza sirul de clienti.
Input:
-
Output:
-
'''
self.__clients = []

def addClient(self,cl):
'''
Functie ce adauga un client in sir.
Input:
-cl, de tip client
Output:
-Eroare, daca exista.
'''
if cl in self.__clients:
raise RepositoryCException("Client existent.")
self.__clients.append(cl)

def remClient(self,cl):
'''
Functie ce sterge un client din sir.
Input:
-cl, de tip client
Output:
-Eroare, daca exista.
'''
if cl not in self.__clients:
raise RepositoryCException("Client inexistent.")
self.__clients.remove(cl)

def updClient(self,cl):
'''
Functie ce modifica un client din sir.
Input:
-cl, de tip client
Output:
-Eroare, daca exista.
'''
if cl not in self.__clients:
raise RepositoryCException("Client inexistent.")
ind = self.__clients.index(cl)
self.__clients[ind] = cl

def getClient(self,cl):
'''
Functie ce returneaza un client din sir.
Input:
-cl, de tip client
Output:
-Eroare, daca exista; clientul altfel.
'''
if cl not in self.__clients:
raise RepositoryCException("Film inexistent.")
ind = self.__clients.index(cl)
return self.__clients[ind]

def sizeList(self):
'''
Functie ce returneaza lungimea sirului de clienti.
Input:
-
Output:
-lungimea sirului.
'''
return len(self.__clients)

def getAllClients(self):
'''
Functie ce returneaza toti clientii.
Input:
-
Output:
-sirul de clienti.
'''
return self.__clients[:]

def searchC(self,nume):
'''
Functie ce returneaza un client din sir, dupa nume.
Input:
-Nume
Output:
-Eroare, daca exista; clientul altfel.
'''
i = 0
while i < len(self.__clients):
if nume == Client.getNume(self.__clients[i]):
return self.__clients[i]
i = i + 1
raise RepositoryCException("Client inexistent.")

You might also like