Class: Game

Inherits:
Object
  • Object
show all
Defined in:
lib/Game.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, output) ⇒ Game


12
13
14
15
16
# File 'lib/Game.rb', line 12

def initialize(input, output)
  @input = input.new
  @output = output
  @file = FileIO.new("data/game_log.json")
end

Instance Attribute Details

#fileObject

Returns the value of attribute file


10
11
12
# File 'lib/Game.rb', line 10

def file
  @file
end

#inputObject

Returns the value of attribute input


10
11
12
# File 'lib/Game.rb', line 10

def input
  @input
end

#outputObject

Returns the value of attribute output


10
11
12
# File 'lib/Game.rb', line 10

def output
  @output
end

Instance Method Details

#startObject


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/Game.rb', line 18

def start
  # Display Game Instruction
  @output.display_start_message

  # Ask user if they want to play
  @input ||= @input.new
  input = @input.get_command

  # process the command
  process_command(input)
end