nonfiction2 = Tome_Rater.create_non_fiction( "Computing Machinery and Intelligence", "AI", "advanced", 11111938) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Add a user with three books already read: #Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) #Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) #Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) #Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) #Uncomment these to test your functions: Tome_Rater.print_book_catalog() Tome_Rater.print_TomeRater_users() # print("Most positive user:") # print(Tome_Rater.most_positive_user())
novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452) nonfiction2 = Tome_Rater.create_non_fiction("Computing Machinery and Intelligence", "AI", "advanced", 11111938) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) #Uncomment these to test your functions: # Tome_Rater.print_catalog() # Tome_Rater.print_users() # print("Most positive user:")
novel3 = tr.create_novel("There Will Come Soft Rains", 1234510001000, "Ray Bradbury") #novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #CREATE USERS tr.add_user("Alan Turing", "*****@*****.**") tr.add_user("David Marr", "*****@*****.**") #Add USER (with BOOKS ARGUMENT) tr.add_user("Marvin Minsky", "*****@*****.**", books=[book1, novel1, nonfiction1]) #tr.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #(User ARGUMENT user_books (DOESN'T EXIST)) #Add BOOK (Alan Turing) tr.add_book_to_user('*****@*****.**', book1, 1) #['None', 1] #(switched the order of arguments) tr.add_book_to_user('*****@*****.**', novel1, 3) #['None', 3] tr.add_book_to_user('*****@*****.**', nonfiction1, 3) #['None', 3] tr.add_book_to_user('*****@*****.**', nonfiction2, 4) #[4] tr.add_book_to_user('*****@*****.**', novel3, 1) #[1] #tr.add_book_to_user(book1, '*****@*****.**', 1) #tr.add_book_to_user(novel1, "*****@*****.**", 3) #tr.add_book_to_user(nonfiction1, "*****@*****.**", 3) #tr.add_book_to_user(nonfiction2, "*****@*****.**", 4) #tr.add_book_to_user(novel3, "*****@*****.**", 1) #Add BOOK (Marvin Minsky) tr.add_book_to_user('*****@*****.**', novel2, 2) #[2] #(switched the order of arguments) tr.add_book_to_user('*****@*****.**', novel3, 2) #[1, 2] #tr.add_book_to_user(novel2, "*****@*****.**", 2) #tr.add_book_to_user(novel3, "*****@*****.**", 2)
book1 = Tome_Rater.create_book("Society of Mind", 12345678) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452) nonfiction2 = Tome_Rater.create_non_fiction("Computing Machinery and Intelligence", "AI", "advanced", 11111938) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) #Uncomment these to test your functions: Tome_Rater.print_catalog() Tome_Rater.print_users() print("Most positive user:")
book2 = Tome_Rater.create_book('Harry Potter', 12345) book3 = Tome_Rater.create_book('Enders Game', 56789) # Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") # Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) Tome_Rater.add_user('Dylan Griffith', '*****@*****.**') Tome_Rater.add_user('Dylan Griffith', '*****@*****.**') # # Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1.5) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1.5) Tome_Rater.add_book_to_user(novel1, '*****@*****.**', 3.2) Tome_Rater.add_book_to_user(book2, '*****@*****.**', 4) Tome_Rater.add_book_to_user(book3, '*****@*****.**', 3.3) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) print('---------------------------------------------------------')
novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) #Uncomment these to test your functions: #Tome_Rater.print_catalog() #Tome_Rater.print_users() #print("Most positive user:") #print(Tome_Rater.most_positive_user())
print(non_fiction1 == non_fiction3) print("Begin tomerater testing\n") print("Testing tomerater1 instance: {}, {}") print(tomerater1.users, tomerater1.books, sep=" , ") print("Testing tomeraterbook1 equal to book2: True") print(tomeraterbook1 == book2) print("Testing tomeraternovel1 equal to fiction1: True") print(tomeraternovel1 == fiction1) print("Testing tomeraternon_fiction1 equal to non_fiction1: True") print(tomeraternon_fiction1 == non_fiction1) print("Testing add_user tomerater1: Beatriz Rodriguez, [email protected], The Book, Henry Book") tomerater1.add_user("Beatriz Rodriguez", "*****@*****.**", [book1, book5]) print(tomerater1.users, tomerater1.books, sep=" , ") print("Testing add_book_to_user tomerater1 user1: That Book") tomerater1.add_book_to_user(tomeraterbook1, "*****@*****.**") print(tomerater1.users, tomerater1.books, sep=" , ") print("Testing print_catalog tomerater1: The Book, That Book, That Book") tomerater1.print_catalog() print("Testing print_users tomerater1: Beatriz Rodriguez, [email protected]") tomerater1.print_users() print("Testing most_read_book tomerater2: Watch My Hand by Nancy P. Magcian") tomerater2.add_user("Beatriz Rodriguez", "*****@*****.**") tomerater2.add_user("Xiomei Li", "*****@*****.**") tomerater2.add_book_to_user(fiction4, "*****@*****.**", 2.5) tomerater2.add_book_to_user(fiction4, "*****@*****.**", 3) tomerater2.add_book_to_user(tomeraternovel1, "*****@*****.**", 4) print(tomerater2.most_read_book()) print("Testing highest_rated_book tomerater3: Untruth by Jim Crowed") tomerater3.add_user("Beatriz Rodriguez", "*****@*****.**") tomerater3.add_user("Xiomei Li", "*****@*****.**")
Tome_Rater.add_user("E: User email without @", "withoutmiukumaukucomputation.org") # Without @ Tome_Rater.add_user("E: User email without ending", "without@ending") # Without domain Tome_Rater.add_user("E: User email without ending and @", "justtextasemail") # Just a string # Add a user with three books already read: Tome_Rater.add_user( "Marvin Minsky", "*****@*****.**", user_books=[book1, book3, novel1, novel2, nonfiction1, nonfiction3]) print("\nTest case: Book price calculations") # Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) # +0 print(Tome_Rater.get_worth_of_user("*****@*****.**"), "should be 0") Tome_Rater.add_book_to_user(book2, "*****@*****.**", 4) # +2.54 print(Tome_Rater.get_worth_of_user("*****@*****.**"), "should be 2.54") Tome_Rater.add_book_to_user(book3, "*****@*****.**", 3) # +64.42 print(Tome_Rater.get_worth_of_user("*****@*****.**"), "should be 66.96") Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) # +0 print(Tome_Rater.get_worth_of_user("*****@*****.**"), "should be 66.96") Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) # +0 print(Tome_Rater.get_worth_of_user("*****@*****.**"), "should be 66.96") Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) # +0 print(Tome_Rater.get_worth_of_user("*****@*****.**"), "should be 66.96") Tome_Rater.add_book_to_user(novel4, "*****@*****.**", 2) # +12.45 print(Tome_Rater.get_worth_of_user("*****@*****.**"), "should be 79.41") Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2)
"Lewis Carroll") nonfiction2 = tr2.create_non_fiction("Automate the Boring Stuff", 1234561929452, "Python", "beginner") tr2.add_user("Marvin Minsky", "*****@*****.**", books=[book2, novel2, nonfiction2]) # trap printout (END) ************************* sys.stdout = sys.__stdout__ # COMPARE OBJECTS (SHOULD RETURN TRUE) print( '***********************************************************************************************' ) print('TEST: COMPARE EQUALITY ON TWO TomeRater OBJECTS') print('Object#1: --------------------') tr1.print_catalog() tr1.print_users() print('Object#2: --------------------') tr2.print_catalog() tr2.print_users() print('Comparison (should be EQUAL): --------------------') print('Is (tr1) equal to (tr2): ', tr1 == tr2) print('Add another USER and retest...') tr1.add_user("Alan Turing", "*****@*****.**") #add user tr1.add_book_to_user('*****@*****.**', book1, 1) #add book (to user) print('Comparison (should be NOT EQUAL): --------------------') print('Is (tr1) equal to (tr2): ', tr1 == tr2) print
novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452) nonfiction2 = Tome_Rater.create_non_fiction("Computing Machinery and Intelligence", "AI", "advanced", 11111938) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1, 10) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3, 7) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3, 22.95) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4, 20) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1, 9) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2, 15) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2, 11.5) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4, 12) #Uncomment these to test your functions: # Tome_Rater.print_catalog() # Tome_Rater.print_users() # print("Most positive user:") # print(Tome_Rater.most_positive_user())
r_ww = rater.create_book('World War II at Sea: A Global History', 190243678) r_man = rater.create_non_fiction('The Society of Mind', 'Artificial Intelligence', 'Beginner', 671657135) r_man2 = rater.create_non_fiction('On Cooking', 'Culinary Arts', 'Expert', 131713272) r_pap = rater.create_novel('Pride and Prejudice', 'Jane Austen', 679783261) para = rater.create_novel('The Parasite', 'Arthur Conan Doyle', 809594374) #################################### USERS ################################## rater.add_user('RDSgmail', '*****@*****.**', user_books=[r_ww, r_pap, r_man]) rater.add_user('RDShotmail', '*****@*****.**') rater.add_user('RDSYahoo', '*****@*****.**') ############################### BOOKS TO USERS ############################## rater.add_book_to_user(r_man2, '*****@*****.**', 3) rater.add_book_to_user(r_man2, '*****@*****.**', 4) rater.add_book_to_user(para, '*****@*****.**', 4) rater.add_book_to_user(para, '*****@*****.**', 3) ############################################################################# print('\n--------------------- Error Handling Checks ----------------------') rater.add_book_to_user(r_man2, '*****@*****.**', 5) rater.add_book_to_user(r_man, '*****@*****.**') rater.add_book_to_user(para, '*****@*****.**', -1) ############################################################################# print('\n-------------------- TomeRater User Community --------------------') for user in rater.users: print('{value}'.format(value=rater.users[user]))
nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452) nonfiction2 = Tome_Rater.create_non_fiction("Computing Machinery and Intelligence", "AI", "advanced", 11111938) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #Create users: print("Create Users") Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: print("Add book to user") Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) #Uncomment these to test your functions: Tome_Rater.print_catalog() Tome_Rater.print_users() print("Most positive user:")
#Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") Tome_Rater.add_user("user1", "*****@*****.**") Tome_Rater.add_user("user2", "*****@*****.**") Tome_Rater.add_user("some dude", "*****@*****.**") Tome_Rater.add_user("my friend", "*****@*****.**") Tome_Rater.add_user("Jim Kabobi", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 1) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 1) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) Tome_Rater.add_book_to_user(book1, "*****@*****.**", 4) #Uncomment these to test your functions: print('\n')
novel1 = tr.create_novel("Alice In Wonderland", 1020304030201, "Lewis Carroll") novel1.isbn.set_isbn(9781536831139) nonfiction1 = tr.create_non_fiction("Automate the Boring Stuff", 1234561929452, "Python", "beginner") nonfiction2 = tr.create_non_fiction("Computing Machinery and Intelligence", 1234511111938, "AI", "advanced") novel2 = tr.create_novel("The Diamond Age", 1234510101010, "Neal Stephenson") novel3 = tr.create_novel("There Will Come Soft Rains", 1234510001000, "Ray Bradbury") #CREATE USERS tr.add_user("Alan Turing", "*****@*****.**") tr.add_user("David Marr", "*****@*****.**") #Add USER (with BOOKS ARGUMENT) tr.add_user("Marvin Minsky", "*****@*****.**", books=[book1, novel1, nonfiction1]) #Add BOOK (to users) tr.add_book_to_user('*****@*****.**', book1, 1) tr.add_book_to_user('*****@*****.**', novel1, 3) tr.add_book_to_user('*****@*****.**', nonfiction1, 3) tr.add_book_to_user('*****@*****.**', nonfiction2, 4) tr.add_book_to_user('*****@*****.**', novel3, 1) tr.add_book_to_user('*****@*****.**', novel2, 2) tr.add_book_to_user('*****@*****.**', novel3, 2) tr.add_book_to_user('*****@*****.**', novel3, 4) # ------------------------------------------ # ------------------------------------------ # TOME RATER (OBJECT#1) # TEST (ADD TWO TOME RATER OBJECTS) # create new object tr1 = TomeRater() # add user
nonfiction3 = Tome_Rater.create_non_fiction("Obey The Testing Goat", "Python", "advanced", 1394098) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") Tome_Rater.add_user("Mitchell Redekopp", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) #Add books to a user one by one, with ratings: Tome_Rater.add_book_to_user(book1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 3) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 1) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 2) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel1, "*****@*****.**", 1) Tome_Rater.add_book_to_user(nonfiction1, "*****@*****.**", 4) Tome_Rater.add_book_to_user(nonfiction2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(nonfiction3, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel2, "*****@*****.**", 4) Tome_Rater.add_book_to_user(novel3, "*****@*****.**", 4)