generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
58 lines (51 loc) · 898 Bytes
/
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
require_relative './app'
@method = App.new
# Main menu
def print_menu
print 'Welcome to my Library! You may perform the following tasks:
1. List all books.
2. List all people
3. Create a person
4. Create a book.
5. Create a rental
6. List all rentals for a given person id.
7. Exit
Choose (1-7): '
end
# Get input from the user
def user_choice
gets.chomp.to_i
end
def display(choice)
case choice
when 1
@method.list_all_books
when 2
@method.list_all_people
when 6
@method.list_all_rentals_id
when 7
@method.quit_app
end
end
def add(choice)
case choice
when 3
@method.create_a_person
when 4
@method.create_a_book
when 5
@method.create_a_rental
end
end
def main(status)
loop do
break unless status
print_menu
user_input = user_choice
display(user_input)
add(user_input)
end
end
main(true)
main.main