forked from rainbough/Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
96 lines (80 loc) · 2.79 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
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",1995,3)
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 "-------------------------"
=begin
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 "list all five books in the library's catalog with their statuses:"
library.list_books
puts "-------------------------"
mike.borrowed_books_list
puts "checking in book"
=end
library.check_in(stranger)
puts "-------------------------"
puts "list all five books in the library's catalog with their statuses:"
library.list_books
puts "-------------------------"
stranger.add_review(mike,5,"loved it")
stranger.add_review(ricardo,4)
stranger.list_reviews