Created
March 12, 2014 21:31
-
-
Save alebaffa/9516835 to your computer and use it in GitHub Desktop.
Week 5 exe 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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