forked from rainbough/Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
104 lines (86 loc) · 3.03 KB
/
main.rb
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
require_relative "library.rb"
puts "create our library"
library = Library.new
puts "-------------------------"
puts "create our borrowers"
mike = Borrower.new("Mike")
ricardo = Borrower.new("Ricardo")
gilbert = Borrower.new("Gilbert")
puts "-------------------------"
puts "create our books"
stranger = Book.new("The Stranger", "Albert Camus")
nausea = Book.new("Nausea", "Jean-Paul Sartre")
karamazov = Book.new("The Brothers Karamazov", "Fyodor Dostoesvky")
feynman = Book.new("Surely You're Joking Mr. Feynman", "Richard Feynman")
finnegan = Book.new("Finnegans Wake", "James Joyce")
k_and_r = Book.new("The C Programming Language", "Kernighan and Ritchie")
puts "-------------------------"
puts "add our books to the library"
library.add_book(stranger)
library.add_book(nausea)
library.add_book(karamazov)
library.add_book(feynman)
library.add_book(finnegan)
library.add_book(k_and_r)
puts "-------------------------"
puts "list all five books in the library's catalog with their status:"
library.list_books
puts "-------------------------"
puts "check out two books for mike"
library.check_out(mike, stranger)
library.check_out(mike, nausea)
puts "-------------------------"
puts "check out two books for gilbert"
library.check_out(gilbert, karamazov)
library.check_out(gilbert, feynman)
puts "-------------------------"
puts "list all five books in the library's catalog with their statuses:"
library.list_books
puts "-------------------------"
puts "try to check out another book for Mike, this should fail since he already
has two out"
library.check_out(mike, finnegan)
puts "-------------------------"
puts "this book should still be available since it failed before"
library.check_out(ricardo, finnegan)
puts "-------------------------"
puts "but this book should fail since it is already checked out"
library.check_out(ricardo, stranger)
puts "-------------------------"
puts "these should return the books each user checked out"
puts ''
puts "mike:"
mike.borrowed_books_list
puts ''
puts "gilbert:"
gilbert.borrowed_books_list
puts ''
puts "ricardo:"
ricardo.borrowed_books_list
puts "-------------------------"
puts "this should only show the borrowed books with their borrowers"
library.borrowed_books
puts "-------------------------"
puts "this should only show the available books"
library.available_books
puts "-------------------------"
puts "add attributes for year-published and edition to some books"
puts stranger.edition = "second edition"
puts karamazov.year_published = "1880"
puts "-------------------------"
puts "return some books and have a user give them a review/rating"
library.check_in(feynman)
library.check_in(finnegan)
puts "-------------------------"
puts "collect more reviews/ratings for Finnegans Wake"
library.check_out(ricardo, finnegan)
library.check_in(finnegan)
puts ''
library.check_out(ricardo, finnegan)
library.check_in(finnegan)
puts "-------------------------"
puts "show the ratings, reviews, and average rating for Finnegans Wake"
finnegan.ratings_list
finnegan.reviews_list
finnegan.avg_rating
puts"--------------------------"