-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpopulate.py
60 lines (48 loc) · 2.25 KB
/
populate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from TomeRater import *
Tome_Rater = TomeRater()
# Create some books:
book1 = Tome_Rater.create_book("Society of Mind", 12345678, 12.00)
novel1 = Tome_Rater.create_novel("Alice In Wonderland", "Lewis Carroll", 12345, 10.00)
novel1.set_isbn(9781536831139)
nonfiction1 = Tome_Rater.create_non_fiction("Automate the Boring Stuff", "Python", "beginner", 1929452, 25.00)
nonfiction2 = Tome_Rater.create_non_fiction("Computing Machinery and Intelligence", "AI", "advanced", 11111938, 30.00)
novel2 = Tome_Rater.create_novel("The Diamond Age", "Neal Stephenson", 10101010, 20.00)
novel3 = Tome_Rater.create_novel("There Will Come Soft Rains", "Ray Bradbury", 10001000, 15.00)
# Create users:
Tome_Rater.add_user("Alan Turing", "[email protected]")
Tome_Rater.add_user("David Marr", "[email protected]")
# Add a user with three books already read:
Tome_Rater.add_user("Marvin Minsky", "[email protected]", user_books=[book1, novel1, nonfiction1])
# Add books to a user one by one, with ratings:
Tome_Rater.add_book_to_user(book1, "[email protected]", 1)
Tome_Rater.add_book_to_user(novel1, "[email protected]", 3)
Tome_Rater.add_book_to_user(nonfiction1, "[email protected]", 3)
Tome_Rater.add_book_to_user(nonfiction2, "[email protected]", 4)
Tome_Rater.add_book_to_user(novel3, "[email protected]", 1)
Tome_Rater.add_book_to_user(novel2, "[email protected]", 2)
Tome_Rater.add_book_to_user(novel3, "[email protected]", 2)
Tome_Rater.add_book_to_user(novel3, "[email protected]", 4)
# Uncomment these to test your functions:
print("Catalog:")
Tome_Rater.print_catalog()
print("Users:")
Tome_Rater.print_users()
print("Most positive user:")
print(Tome_Rater.most_positive_user())
print("Highest rated book:")
print(Tome_Rater.highest_rated_book())
print("Most read book:")
print(Tome_Rater.get_most_read_book())
# Add user with invalid e-mail address
#Tome_Rater.add_user("Test User", "test@test")
# Attempt to create a book object with an existing ISBN (should fail)
#novel4 = Tome_Rater.create_novel("Through The Looking Glass", "Lewis Carroll", 12345678, 10.00)
print(Tome_Rater)
print()
print(Tome_Rater.get_n_most_read_books(4))
print()
print(Tome_Rater.get_n_most_prolific_readers(4))
print()
print(Tome_Rater.get_n_most_expensive_books(3))
print()
print(Tome_Rater.get_worth_of_user("[email protected]"))