def moviesInitialize(self): movieRepo = Repository() movieTitles = [ "The Godfather", "The Shawshank Redemption", "Schindler's List", "Raging Bull", "Casablanca", "Citizen Kane", "Gone with the Wind", "The Wizard of Oz ", "One Flew Over the Cuckoo's Nest" ] descriptionList = [ "Sure! Why not?", "Yea boi", "Best movie.", "Don't watch it with your mother", "18+", "1/10", "Do not recommend", "5/10", "Cry by yourself" ] genreMovies = ["Drama", "Comedy", "Horror", "Action", "SF"] i = 0 while i <= 100: movieRepo.add( Movie( ((i * 5 + 1 + i % 2 + 3) // 2), random.choice(movieTitles), random.choice(descriptionList), random.choice(genreMovies))) #print(movieRepo._list[i]) i += 1 return movieRepo
def clientsInitialize(self): clientRepo = Repository() firstName = [ "Bogdan", "Andrei", "Cristi", "Patrick", "Gabriel", "Laura", "Alexandra", "Andreea", "Robert", "Claudiu", "Mirel", "Carmen", "Darius", "Robert", "Macanache" ] secondName = [ "Suciu", "Petru", "Andras", "Pop", "Cosmulei", "Micu", "Crivei", "Bota", "Botis", "Stejerean", "Vincze", "Somotecan", "Salvia" ] i = 0 while i <= 100: clientRepo.add( Client((i * 4 + i % 3 + 1) // 2 + 1, random.choice(firstName) + " " + random.choice(secondName))) i += 1 i = 0 while i < len(clientRepo._list): # print(clientRepo._list[i]) i += 1 return clientRepo
def readFromFile(self): try: f = open(self._fileName, "r") line = f.readline() while len(line) > 0: parts = line.split(";") client = Client(int(parts[0]), parts[1]) Repository.add(self, client) line = f.readline() f.close() except: pass
def add(self, client): Repository.add(self, client) self.writeToFile()