Skip to content

Instantly share code, notes, and snippets.

@alebaffa
Created March 12, 2014 21:31
Show Gist options
  • Save alebaffa/9516835 to your computer and use it in GitHub Desktop.
Save alebaffa/9516835 to your computer and use it in GitHub Desktop.
Week 5 exe 3
class GameBoard
def initialize
@range = [0,1,2,3,4,5,6]
@no_of_hits = 0
end
def set_locations_cells(locations)
@numbers_to_guess = []
locations.each{|index| @numbers_to_guess.push(@range[index])}
end
def check_yourself(user_guess)
if @numbers_to_guess.include?(user_guess.to_i)
@no_of_hits +=1
puts 'Hit'
kill?
else
puts 'Miss'
end
end
def kill?
if @no_of_hits == 3
puts 'End'
'kill'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment