Exemplo n.º 1
0
 def get_clientfull():
     try:
         id = int(input("Client ID: "))
         name = input("Client name: ")
     except:
         raise Exception("Invalid Data")
     return client(str(id), name)
 def loadFromFile(self):
     try:
         f = open(self._fileName, "r")
         line = f.readline().strip()
         while line != "":
             attrs = line.split(" ")
             client1 = client(attrs[0], attrs[1])
             clients.addClient(self, client1)
             line = f.readline().strip()
     except:
         raise Exception("Could not load from File!")
     finally:
         f.close()
Exemplo n.º 3
0
 def f_update(self, *args):
     print(ui.print_update_choices())
     cmd = ui.read_add_remove_cmd()
     if cmd == '1':
         searchId = ui.get_id()
         args = ui.get_book_args()
         try:
             self._books.book_ctrl_update(searchId, args)
         except Exception as x:
             print(x)
     elif cmd == '2':
         searchId = ui.get_id()
         clientName = ui.get_client()
         try:
             self._clients.client_ctrl_update(searchId,
                                              client(searchId, clientName))
         except Exception as x:
             print(x)
Exemplo n.º 4
0
clientsRepo = clients()
rentalsRepo = rentalList()

booksFile = open("books.txt", 'r+')
clientsFile = open("clients.txt", 'r+')
rentalsFile = open("rentals.txt", 'r+')

for i in range(1, 101):
    line = booksFile.readline()
    line = line.split(" ")
    booksRepo.addBook(book(line[0], line[1], line[2], line[3]))

for i in range(1, 101):
    line = clientsFile.readline()
    line = line.split(" ")
    clientsRepo.addClient(client(line[0], line[1]))

for i in range(1, 101):
    line = rentalsFile.readline()
    line = line.split(" ")

    #date 1 3-day-4-5-yr
    #date 2 6-7-8
    date1 = datetime(int(line[5]), int(line[4]), int(line[3]))
    date2 = datetime(int(line[8]), int(line[7]), int(line[6]))
    newRental = rental(line[0], line[1], line[2], date1, date2)
    rentalsRepo.rentBook(newRental)

undoController = UndoController()
rentalsCtrlUndo = RentalsControllerUndo(undoController, rentalsRepo, booksRepo,
                                        clientsRepo)
Exemplo n.º 5
0
booksRepo = bookList()
clientsRepo = clients()
rentalsRepo = rentalList()

booksRepo.addBook(book("1", "HP", "Best", "JkR"))
booksRepo.addBook(book("2", "HitchHiker", "Voted", "Douglas Adams"))
booksRepo.addBook(book("3", "py", "as", "andrei"))
booksRepo.addBook(book("4", "Anna", "drama", "T"))
booksRepo.addBook(book("5", "Pride and Prejudice", "Russian", "D"))
booksRepo.addBook(book("6", "Don Quixote", "Classic", "Cervantes"))
booksRepo.addBook(book("7", "1984", "Dystopia", "Orwell"))
booksRepo.addBook(book("8", "War and Peace", "Classic", "Tolstoy"))
booksRepo.addBook(book("9", "The great Gatsby", "Movie", "Fitzgerald"))
booksRepo.addBook(book("10", "Ulysses", "Greek", "James Joyce"))

clientsRepo.addClient(client("11", "Lacy Soza"))
clientsRepo.addClient(client("12", "Dorian Sivilis"))
clientsRepo.addClient(client("13", "China Nissen"))
clientsRepo.addClient(client("14", "Jessia Orlando"))
clientsRepo.addClient(client("15", "Fredda Nalls"))
clientsRepo.addClient(client("16", "Rochell Jump"))
clientsRepo.addClient(client("17", "Devon Darville"))

rentalsRepo.rentBook(
    rental("1", "1", "11", datetime(10, 10, 10), datetime(11, 11, 11)))
rentalsRepo._rentalList[0].returnBook(datetime(11, 11, 11))
rentalsRepo.rentBook(
    rental("2", "2", "12", datetime(10, 10, 10), datetime(11, 11, 11)))
rentalsRepo._rentalList[1].returnBook(datetime(11, 11, 11))
rentalsRepo.rentBook(
    rental("3", "3", "11", datetime(11, 11, 11), datetime(11, 12, 11)))