def _addRental(self, rentalId, movieId, clientId, dueDate, U=""): if self._userOk(clientId) and self._movieOk(movieId): self._rentals.append(Rental(rentalId, movieId, clientId, self._globalDate, dueDate)) if U != "U": self._stack.append(StackObject("self._removeRental", [rentalId])) self._helpStack.append(StackObject("self._addRental", [rentalId, movieId, clientId, dueDate])) self._redoStack.clear()
def _deleteRental(self, movieId, U=""): for rental in self._rentals: if rental.MovieId == movieId: if U != "U": self._stack.append(StackObject("self._undoReturn", [movieId])) self._helpStack.append(StackObject("self._deleteRental", [movieId])) self._redoStack.clear() rental.ReturnedDate = self._globalDate break
def _addClient(self, newId, newName, U=""): ''' Function adds a client to the list ''' self._clients.append(Client(newId, newName)) if U != "U": self._stack.append(StackObject("self._removeClient", [newId])) self._helpStack.append(StackObject("self._addClient", [newId, newName])) self._redoStack.clear()
def _addMovie(self, newId, newTitle, newDesc, newGenre, U=""): ''' Function adds a movie to the list ''' self._movies.append(Movie(newId, newTitle, newDesc, newGenre)) if U != "U": self._stack.append(StackObject("self._removeMovie", [newId])) self._helpStack.append(StackObject("self._addMovie", [newId, newTitle, newDesc, newGenre])) self._redoStack.clear()
def _updateClient(self, newId, newName, U=""): ''' Function updates a client in the list ''' for client in self._clients: if client.Id == newId: if U != "U": self._stack.append(StackObject("self._updateClient", [client.Id, client.Name])) self._helpStack.append(StackObject("self._updateClient", [newId, newName])) self._redoStack.clear() client.Name = newName
def _updateMovie(self, newId, newTitle, newDesc, newGenre, U=""): ''' Function updates a movie in the list ''' for movie in self._movies: if movie.Id == newId: if U != "U": self._stack.append(StackObject("self._updateMovie", [movie.Id, movie.Title, movie.Description, movie.Genre])) self._helpStack.append(StackObject("self._updateMovie", [newId, newTitle, newDesc, newGenre])) self._redoStack.clear() movie.Title = newTitle movie.Description = newDesc movie.Genre = newGenre
def _removeMovie(self, newId, U=""): ''' Function removes a movie from the list ''' i = 0 while i < len(self._movies): if self._movies[i].Id == newId: if U != "U": self._stack.append(StackObject("self._addMovie", [self._movies[i].Id, self._movies[i].Title, self._movies[i].Description, self._movies[i].Genre])) self._helpStack.append(StackObject("self._removeMovie", [newId])) self._redoStack.clear() self._movies.remove(self._movies[i]) i = i-1 i = i+1
def _removeClient(self, newId, U=""): ''' Function removes a client from the list ''' i = 0 while i < len(self._clients): if self._clients[i].Id == newId: if U != "U": self._stack.append(StackObject("self._addClient", [self._clients[i].Id, self._clients[i].Name])) self._helpStack.append(StackObject("self._removeClient", [newId])) self._redoStack.clear() self._clients.remove(self._clients[i]) i = i-1 i = i+1