-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
62 lines (54 loc) · 1.19 KB
/
app.rb
File metadata and controls
62 lines (54 loc) · 1.19 KB
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
require_relative 'person'
require_relative 'student'
require_relative 'classroom'
require_relative 'teacher'
require_relative 'rental'
require_relative 'book'
class App
def initialize
puts 'Welcome to School Library App!'
# load data from json files
Book.load_books
Student.load_students
Teacher.load_teachers
end
def prompt
puts
puts 'Please choose an option by entering a number:'
puts '1 - List all books'
puts '2 - List all people'
puts '3 - Create a person'
puts '4 - Create a book'
puts '5 - Create a rental'
puts '6 - List all rentals for a given person id'
puts '7 - Exit'
end
def navigator(option)
case option
when '1'
Book.list_books
when '2'
Person.list_people
when '3'
Person.create_person
when '4'
Book.create_book
when '5'
Rental.create_rental
when '6'
Rental.list_rentals
else
puts 'That is not a valid option'
end
end
def run
prompt
option = gets.chomp
if option == '7'
puts 'Thank you for using this App!'
exit
end
navigator(option)
run
end
end