forked from unorjikingsley/Catalog-of-my-things
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
52 lines (47 loc) · 1.19 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
require_relative 'app'
class Main
def initialize
@app = App.new
prompt
end
def prompt
puts 'Catalogue of things!'
loop do
display_options
option = take_input
if option >= 1 && option < 7
@app.run_till6(option)
else
@app.run_more_than6(option)
end
break if option == 13
end
end
def display_options
puts 'Please choose one of the options: '
puts '1. - List all books'
puts '2. - List all music albums'
puts '3. - List all movies'
puts '4. - List all games'
puts "5. - List all genres (e.g 'Comedy', 'Thriller')"
puts "6. - List all labels (e.g. 'Gift', 'New')"
puts "7. - List all authors (e.g. 'Stephen King')"
puts "8. - List all sources (e.g. 'From a friend', 'Online shop')"
puts '9. - Add book'
puts '10. - Add a music album'
puts '11. - Add movie'
puts '12. - Add a game'
puts '13. - Exit'
end
def take_input
print 'Enter a number: '
option = gets.chomp.to_i
while option.nil? || option < 1 || option > 13
puts 'Please enter a number between 1 and 4!'
print 'Enter a number: '
option = gets.chomp.to_i
end
option
end
end
Main.new