-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.rb
76 lines (69 loc) · 1.4 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
require './app'
puts 'Welcome to your Catalog of things'
class Menu
def initialize(app)
@app = app
end
def display_menu
puts '===== Library Menu ====='
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'
puts '6. List all labels'
puts '7. List all authors'
puts '8. List all sources'
puts '9. Add a book'
puts '10. Add a music album'
puts '11. Add a movie'
puts '12. Add a game'
puts '13. Exit'
end
def run_options(choice)
case choice
when 1
@app.list_all_books
when 2
@app.list_all_music_albums
when 3
@app.list_all_movies
when 4
@app.list_all_games
when 5
@app.list_all_genres
when 6
@app.list_all_labels
when 7
@app.list_all_authors
when 8
@app.list_all_sources
when 9
@app.add_book
when 10
@app.add_music_album
when 11
@app.add_movie
when 12
@app.add_game
else
puts 'Invalid option. Please try again.'
end
end
end
app_instance = App.new
menu = Menu.new(app_instance)
loop do
menu.display_menu
print 'Enter your choice (1 - 13): '
choice = gets.to_i
case choice
when 1..12
menu.run_options(choice)
when 13
puts 'Exiting the app'
break
else
puts 'Invalid choice. Please input a valid choice'
end
end