Class: DsaCodebreakerGame::Gamer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGamer

Returns a new instance of Gamer.



7
8
9
10
11
# File 'lib/dsa_codebreaker_game/gamer.rb', line 7

def initialize
  @lives = 8
  @history = []
  @guess = ['_','_','_','_']
end

Instance Attribute Details

#guessObject

Returns the value of attribute guess.



5
6
7
# File 'lib/dsa_codebreaker_game/gamer.rb', line 5

def guess
  @guess
end

#historyObject

Returns the value of attribute history.



5
6
7
# File 'lib/dsa_codebreaker_game/gamer.rb', line 5

def history
  @history
end

#livesObject

Returns the value of attribute lives.



5
6
7
# File 'lib/dsa_codebreaker_game/gamer.rb', line 5

def lives
  @lives
end

Instance Method Details

#died?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/dsa_codebreaker_game/gamer.rb', line 17

def died?
  @lives < 0
end

#lost_a_lifeObject



13
14
15
# File 'lib/dsa_codebreaker_game/gamer.rb', line 13

def lost_a_life
  @lives -= 1
end