generated from ger619/ruby-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
game_methods.rb
39 lines (35 loc) · 1.1 KB
/
game_methods.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
require_relative './app'
require_relative './game'
def list_games
if @game_list.empty?
puts 'Game list is empty'
else
@game_list.each_with_index do |game, index|
puts "(#{index}) ID: #{game.id} Multiplayer: \"#{game.multiplayer}\", Last Played: #{game.last_played_at}, Published Year: #{game.publish_date} Archived: #{game.archived}" # rubocop:disable Layout/LineLength
end
end
end
def create_game
print 'Multiplayer [y/n]: '
multiplayer = gets.chomp
print 'Last played at [yyyy/mm/dd]: '
last_played_at = gets.chomp
puts 'Please state when was the game published [yyyy/mm/dd]:'
publish_date = gets.chomp
print 'Game Added Succesfully'
new_game = Game.new(multiplayer, last_played_at, publish_date)
@game_list << new_game
end
def add_game(multiplayer, last_played_at, publish_date)
new_game = Game.new(multiplayer, last_played_at, publish_date)
@game_list << new_game
end
def list_genres
if @genre_list.empty?
puts 'Genre list is empty'
else
@genre_list.each_with_index do |genre, index|
puts "(#{index}) Genre Name: \"#{genre.name}\""
end
end
end