from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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) #this is a bad book - it duplicates the previous ISBN. bad_novel = Tome_Rater.create_novel("This should bomb", "Ray Bradbury", 10001000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") Tome_Rater.add_user("Alan Turing", "*****@*****.**") # Try to create a user with a bad email address - should generate an error. Tome_Rater.add_user("Jane Austen", "*****@*****.**") Tome_Rater.add_user("Ruth Bader Ginsburg", "rbg_at_justice.org")
from TomeRater import * Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678, 1.5) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345, 1.99) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452, 8) nonfiction2 = Tome_Rater.create_non_fiction( "Computing Machinery and Intelligence", "AI", "advanced", 11111938, 9.95) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010, 14) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000, 18.99) novel4 = Tome_Rater.create_novel("This Book Has A Duplicate ISBN", "Bogus Fakery", 10001000, 22.00) novel5 = Tome_Rater.create_novel( "The Never Read Book - The Price of Being Too Expensive", "Greedy McMoneybags", 987654321, 100) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #intentionally bogus email address for checking function Tome_Rater.add_user("David Marr", "davidcomputation.org") #intentionally bogus email address for checking function Tome_Rater.add_user("David Marr", "*****@*****.**")
from TomeRater import * # TESTING (for TomeRater.py) # Dean Jones, Sep.15, 2018 # This file has been modified to run # The order of attributes is a bit different # The ISBN number (class) I added (requires 13 digits) # There where some inconsistencies (with the naming)(between the INSTRUCTIONS and THIS FILE) calling methods #CREATE OBJECT (TomeRater) tr = TomeRater() #CREATE BOOKS book1 = tr.create_book("Society of Mind", 1234512345678) #All (ISBN) (require 13 digits) novel1 = tr.create_novel("Alice In Wonderland", 1020304030201, "Lewis Carroll") #novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345) novel1.isbn.set_isbn(9781536831139) #novel1.set_isbn(9781536831139) nonfiction1 = tr.create_non_fiction("Automate the Boring Stuff", 1234561929452, "Python", "beginner") #nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452) nonfiction2 = tr.create_non_fiction("Computing Machinery and Intelligence", 1234511111938, "AI", "advanced") #nonfiction2 = Tome_Rater.create_non_fiction("Computing Machinery and Intelligence", "AI", "advanced", 11111938) novel2 = tr.create_novel("The Diamond Age", 1234510101010, "Neal Stephenson") #novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678, 10) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345, 20) 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, 30) print("Create novel with invalid price:") novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010, -13) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000, 50) #Set price to some books afterwards novel2.set_price(60) novel1.set_price(99.90) print("Set invalid prices:") nonfiction1.set_price("asdf") nonfiction1.set_price(-4000) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**")
from TomeRater import * Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678, 10) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345, 20) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452, 30) nonfiction2 = Tome_Rater.create_non_fiction( "Computing Machinery and Intelligence", "AI", "advanced", 11111938, 40) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010, 50) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000, 60) #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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 1234567891, 34.00) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 8767954325, 45.50) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452090, 22.50) nonfiction2 = Tome_Rater.create_non_fiction( "Computing Machinery and Intelligence", "AI", "advanced", 1111193899, 110.00) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 1010101010, 15.25) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 1000100011, 21.50) #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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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) #Test already existing ISBN book2 = Tome_Rater.create_book("Das fliegende Klassenzimmer", 12345678) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") #Test if email-address already exists #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]) #Test if email-address is valid Tome_Rater.add_user("Hans Meier", "*****@*****.**",
from TomeRater import * Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345) novel1.set_isbn(9781536831139) book1.set_isbn(978153683113) 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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", "*****@*****.**") 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])
from TomeRater import * #TEST (CONCATENATION)(+)(__add__)(with + operator) # ------------------------------------------ # TOME RATER (OBJECT#2)(default from populate.py) #CREATE OBJECT (TomeRater) tr = TomeRater() #CREATE BOOKS book1 = tr.create_book("Society of Mind", 1234512345678) #All (ISBN) (require 13 digits) 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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", "*****@*****.**", 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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)
############################################################################# ############################# Instance Objects ############################## ############################################################################# rds = User('Rich', '*****@*****.**') dsr = User('RichieRich', '*****@*****.**') richEeyore = User('Rich', '*****@*****.**') ww2 = Book('World War II at Sea: A Global History', 190243678) ww3 = Book('World War II at Sea: A Global History', 190243678) pap = Fiction('Pride and Prejudice', 'Jane Austen', 679783261) pap2 = Fiction('Pride and Prejudice', 'Jane Austen', 679783261) man0 = Non_Fiction('The Society of Mind', 'Artificial Intelligence', 'Beginner', 671657135) man1 = Non_Fiction('On Cooking', 'Culinary', 'Expert', 131713272) man2 = Non_Fiction('On Cooking', 'Culinary Arts', 'Expert', 131713272) rater = TomeRater() print('==================================================================') print('==================== TESTING TomeRater Class =====================') print('==================================================================') ##################################### BOOKS ################################# 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)
from TomeRater import * Tome_Rater = TomeRater() Tome_Rater_Backup = Tome_Rater # Create some books with some tests: print("\nTest case: Few broken books created") book_error = Tome_Rater.create_book("Society of Mind", None) # ISBN missing - error book_error2 = Tome_Rater.create_book(12345, 12345) # Book name is not a string book1 = Tome_Rater.create_book("Society of Mind", 12345678) print(book1) book2 = Tome_Rater.create_book("Food for coders", 84372672, 2.54) print(book2) book3 = Tome_Rater.create_book("Loops and hoops", 385874323, 64.42) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345) novel1.set_isbn(9781536831139) novel_error = Tome_Rater.create_novel( "Alice In Wonderland", "Lewis Carroll", 12345) # Same book twice, however ISBN is different and should be accepted 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) nonfiction3 = Tome_Rater.create_non_fiction("Computers", "Graphics", "turbo", 134451313, 34.55) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) novel4 = Tome_Rater.create_novel("The ABC's of programming", "John Doe",
from TomeRater import * import copy Tome_Rater = TomeRater() #Create some books: 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 book with duplicate ISBN book2 = Tome_Rater.create_book("1984", 12345678) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Create user with duplicate email Tome_Rater.add_user("Alan Jackson", "*****@*****.**") #Create users with invalid email addresses Tome_Rater.add_user("Bill Gates", "gatesmicrosoft.com") Tome_Rater.add_user("Steve Wozniak", "*****@*****.**")
from TomeRater import * Tome_Rater = TomeRater() # Create some books: 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) 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)
from TomeRater import * import io import sys # ---------------------------------------------------------------------------- # TOME RATER (EQUALITY)(__eq__)(==)(COMPARE EQUALITY ON TWO TomeRater OBJECTS) # trap printout (START) ************************* trap = io.StringIO() sys.stdout = trap # OBJECT#1 tr1 = TomeRater() book1 = tr1.create_book("Society of Mind", 1234512345678) novel1 = tr1.create_novel("Alice In Wonderland", 1020304030201, "Lewis Carroll") nonfiction1 = tr1.create_non_fiction("Automate the Boring Stuff", 1234561929452, "Python", "beginner") tr1.add_user("Marvin Minsky", "*****@*****.**", books=[book1, novel1, nonfiction1]) # OBJECT#2 tr2 = TomeRater() book2 = tr2.create_book("Society of Mind", 1234512345678) novel2 = tr2.create_novel("Alice In Wonderland", 1020304030201, "Lewis Carroll")
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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", 10101010, "Neal Stephenson") # changed order of parameters to match method novel3 = Tome_Rater.create_novel( "There Will Come Soft Rains", 10001000, "Ray Bradbury") # changed order of parameters to match method #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", "*****@*****.**", 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)
book5 = Book("Harvey Book", 123999, 22) print("Creating Fictions") fiction1 = Fiction("Untruth", 122345, "Jim Crowed", 90) fiction2 = Fiction("Half Truth", 122456, "William T. Conker", 23) fiction3 = Fiction("Look Over There", 122980, "Jefferson Jeffries", 54) fiction4 = Fiction("Watch My Hand", 122999, "Nancy P. Magcian", 657) fiction5 = Fiction("Watch My Hand", 122999, "Umaq Umaqraq", 34500) print("Creating Non_Fiction") non_fiction1 = Non_Fiction("Python for Dummies", 111999, "Beginner", "Programming", 22.9) non_fiction2 = Non_Fiction("Python Cookbook", 111998, "Beginner", "Programming", 22.9) non_fiction3 = Non_Fiction("Python for Dummies", 111999, "Advanced", "Snakes", 35) print("Creating TomeRaters") tomerater1 = TomeRater() tomerater2 = TomeRater() tomerater3 = TomeRater() tomerater4 = TomeRater() print("Creating TomeRaterBook") tomeraterbook1 = tomerater1.create_book("That Book", 123908, 13) print("Creating TomeRaterNovel") tomeraternovel1 = tomerater1.create_novel("Untruth", "Jim Crowed", 122345, 90) print("Creating TomerRaterNon_Fiction") tomeraternon_fiction1 = tomerater1.create_non_fiction("Python for Dummies", "Beginner", "Programming", 111999, 22.9) print("Begin users testing\n") print("Testing user1 instance: Beatriz Rodriguez, [email protected], {}")
from TomeRater import * Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678, 5.65) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345, 6.25) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452, 12.10) nonfiction2 = Tome_Rater.create_non_fiction( "Computing Machinery and Intelligence", "AI", "advanced", 11111938, 8.00) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000, 4.70) novel4 = Tome_Rater.create_novel("Hallelujah", "John Doe Jr", 10001000, 7.75) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") Tome_Rater.add_user("David Double", "*****@*****.**") #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:
from TomeRater import * Tome_Rater = TomeRater() # Create some books: 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) novel4 = Tome_Rater.create_novel("The Hobbit", "J.R.R. Tolkien", 10002001) novel5 = Tome_Rater.create_novel("The Fellowship of the Ring", "J.R.R. Tolkien", 10002002) novel6 = Tome_Rater.create_novel("The Two Towers", "J.R.R. Tolkien", 10002003) novel7 = Tome_Rater.create_novel("The Return of the King", "J.R.R. Tolkien", 10002004) # Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") Tome_Rater.add_user("Alice Test", "*****@*****.**") Tome_Rater.add_user("Bob Test", "*****@*****.**") Tome_Rater.add_user("Carly Test", "*****@*****.**") # 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678, 12) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345, 19) novel1.set_isbn(9781536831139) print('') nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452, 24) nonfiction2 = Tome_Rater.create_non_fiction("Computing Machinery and Intelligence", "AI", "advanced", 11111938, 13) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010, 31) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000, 22) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") #Tome_Rater.add_user("Pavel Ivanov", "*****@*****.**") #Add a user with three books already read: Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) Tome_Rater.add_user("Pavel Ivanov", "*****@*****.**", user_books=[novel3, nonfiction2, nonfiction1, book1]) #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)
from TomeRater import * Tome_Rater = TomeRater() Tome_Rater2 = TomeRater() Tome_Rater3 = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678, 11) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345, 30) novel1.set_isbn(9781536831139) nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452, 20) nonfiction2 = Tome_Rater.create_non_fiction( "Computing Machinery and Intelligence", "AI", "advanced", 11111938, 50) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010, 13) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000, 22) #Create users: Tome_Rater.add_user("Alan Turing", "*****@*****.**") Tome_Rater.add_user("David Marr", "*****@*****.**") Tome_Rater.add_user("David", "*****@*****.**") Tome_Rater.add_user("Marr", "*****@*****.**") Tome_Rater.add_user("Troll Marr", "*****@*****.**") Tome_Rater.add_user("David Troll", "davidacomputation.org") #Add a user with three books already read: #Tome_Rater.add_user("Marvin Minsky", "*****@*****.**", user_books=[book1, novel1, nonfiction1]) Tome_Rater.add_user("Marvin Minsky", "*****@*****.**",
from EmailUtil import * from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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)
from TomeRater import * print() #give me some space print() #give me some space Tome_Rater = TomeRater() #Create some books: book1 = Tome_Rater.create_book("Society of Mind", 12345678) novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345) novel1.set_isbn(9781536831139) #will print a message 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)
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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, 25) nonfiction2 = Tome_Rater.create_non_fiction( "Computing Machinery and Intelligence", "AI", "advanced", 11111938, 30) novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010, 50) novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000) book_same_isbn = Tome_Rater.create_book("Book with same ISBN", 10101010) #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)
from TomeRater import * Tome_Rater = TomeRater() class User: def __init__(self, name, email): self.name = name self.email = email self.books = {} def get_email(self): return self.email def change_email(self, new_email): print("User's email has been updated from", self.email, "to", new_email) self.email = new_email def __repr__(self): return "User " + self.name + ", email: " + self.email + ", books read: " + str(len(self.books)) def __eq__(self, other): if self.name == other.name: return self.email == other.email return False def read_book(self, book, rating = None): self.books[book] = rating #below is not efficient, come back def get_average_rating(self): ratings = []
from TomeRater import * Tome_Rater = TomeRater() #Create some books: 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) 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)