def test_etagere_addBook(self): etagere = Library() etagere.biblio = {} livre = Book("John", "Grisham", "The Racketeer", "International Bestseller", 2013, "Novel", 382, "Chambre de Cyril", 4, "Et voici un autre commentaire blablab abbla.", "The Racketeer.jpg") etagere.addBook(livre) self.assertEqual(len(etagere.dLibrary), 1)
def main(): # Start timer execution start = time.time() # Read static data from json file (10 books) with open(DATA_PATH) as json_file: jsonBookList = json.load(json_file) # Create book objects library = Library([]) for book in jsonBookList: b = Book(book['isbn'], book['title'], book['summary'], book['author']) library.addBook(b) # create new Library with books book = Book(isbn="319069696-F", title="New title", summary=" it's about the New Title", author="author") print('\n****************** Welcome to our Library :) *****************\n') print( "\n******************************************************************\n" ) # Add a new book to the library library.addBook(book) # Count of book in the library print(library.__str__()) # Get all books from library library.getBookList() # Start timer execution end = time.time() print("Executed in %ss ...%s" % (round(end - start, 2), "Bye !"))
print("\n") book1 = Book("The 48 Laws of Power", "Robert Greene", "Penguin Books", "September 1, 2000", 452) book2 = Book("The Art of War", "Sun Tzu", "Greyhound Press", "April 7, 2017", 38) book3 = Book("12 Rules for Life: An Antidote to Chaos", "Jordan B. Peterson", "Random House Canada", "January 23, 2018", 416) book4 = Book("Selected Writings and Speeches of Marcus Garvey", "Marcus Garvey", "Dover Publications", "March 5, 2012", 226) book5 = Book("How Democracies Die", "Steven Levitsky", "Crown", "January 16, 2018", 320) book6 = Book("The Mis-Education of the Negro", "Carter Godwin Woodson", "CreateSpace Independent Publishing Platform", "August 18, 2017", 92) mainBranch = Library("Main Library", "West Palm Beach", 33406) greenBranch = Library("Greenacres Branch", "Greenacres", 33467) mainBranch.addBook(book1) mainBranch.addBook(book2) mainBranch.addBook(book3) greenBranch.addBook(book4) greenBranch.addBook(book5) greenBranch.addBook(book6) mainBranch.printBooks() print("\n") greenBranch.printBooks()
from Library import Library from Book import Book library = Library() test_book = Book('Bülbülü Öldürmek', 1960, 357, 'Harper Lee') test_book2 = Book('Aşk-ı Memnu', 1968, 856, 'Halit Ziya Uşaklıgil') library.addBook(test_book) library.addBook(test_book2) print('Hello Reader!') questions = "1: If you want to add a new book:\n" \ "2: If you want to remove a book:\n" \ "3: If you want to borrow a new book: \n" \ "4: If you want to bring your old book:\n" \ "5: If you want to see our library book list:\n" \ "6: If you want to quit:" isQuit = False while not isQuit: print(questions) selection = input("Please select a number from above: ") if int(selection) == 1: name = input("Please write your new book's name: ") year = input("Please write your new book's publish year: ") n_page = input("Please write your new book's number of page: ") author = input("Please write your new book's author: ") new_book = Book(name, year, n_page, author) result = library.addBook(new_book) if result: print("Thanks for your addition") else:
def test_etagere_addBook(self): etagere = Library() etagere.biblio = {} livre = Book("John","Grisham","The Racketeer","International Bestseller",2013,"Novel",382,"Chambre de Cyril",4,"Et voici un autre commentaire blablab abbla.","The Racketeer.jpg") etagere.addBook(livre) self.assertEqual(len(etagere.dLibrary), 1)
libraries = [] books = [] #reading general info file = open("test_cases/b_read_on.txt", "r") numOfBooks, numOfLibrary, scanningDays = file.readline().split() ## read scores for books booksScores = file.readline().split() for i in range(int(numOfBooks)): bo = Book(i, int(booksScores.__getitem__(i))) books.append(bo) ## reads library general info for i in range(int(numOfLibrary)): libNumBooks, signUpTime, scanningLimit = file.readline().split() lib = Library(i, signUpTime, libNumBooks, scanningLimit) booksInLib = file.readline().split() for j in range(int(lib.numBooks)): lib.addBook(books.__getitem__(int(booksInLib.__getitem__(j)))) libraries.append(lib) lib.toString() optimize(libraries, scanningDays)