You are on page 1of 2

class RepositoryMException(Exception):

def __init__(self, *args):


pass

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

def addMovie(self,mov):
'''
Functie ce adauga un film in sir.
Input:
-mov, de tip movie
Output:
-Eroare, daca exista.
'''
if mov in self.__movies:
raise RepositoryMException("Film existent.")
self.__movies.append(mov)

def remMovie(self,mov):
'''
Functie ce sterge un film din sir.
Input:
-mov, de tip movie
Output:
-Eroare, daca exista.
'''
if mov not in self.__movies:
raise RepositoryMException("Film inexistent.")
self.__movies.remove(mov)

def updMovie(self,mov):
'''
Functie ce modifica un film din sir.
Input:
-mov, de tip movie
Output:
-Eroare, daca exista.
'''
if mov not in self.__movies:
raise RepositoryMException("Film inexistent.")
ind = self.__movies.index(mov)
self.__movies[ind] = mov

def getMovie(self,mov):
'''
Functie ce returneaza un film din sir.
Input:
-mov, de tip movie
Output:
-Eroare, daca exista; filmul altfel.
'''
if mov not in self.__movies:
raise RepositoryMException("Film inexistent.")
ind = self.__movies.index(mov)
return self.__movies[ind]

def searchM(self,titlu):
'''
Functie ce returneaza un film din sir, dupa titlu.
Input:
-Titlu
Output:
-Eroare, daca exista; filmul altfel.
'''
i = 0
while i < len(self.__movies):
if titlu == Movie.getTitlu(self.__movies[i]):
return self.__movies[i]
i = i + 1
raise RepositoryMException("Film inexistent.")

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

def getAllMovies(self):
'''
Functie ce returneaza toate filmele.
Input:
-
Output:
-sirul de filme.
'''
return self.__movies[:]