Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add position occupied method
  • Loading branch information
edgenard committed Apr 3, 2018
1 parent 194ce3a commit 4ccb073
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tic-tac-toe/tic_tac_toe.rb
Expand Up @@ -32,12 +32,16 @@ def winner
end

def winning_player(position)
if board[position] != '-' && board[position] == board[position.next] && board[position.next] == board[position.next.next]
if position_occupied?(position) && board[position] == board[position.next] && board[position.next] == board[position.next.next]
return board[position]
end
end

def position_unoccupied?(position)
board[position] == '-'
end

def position_occupied?(position)
board[position] != '-'
end
end

0 comments on commit 4ccb073

Please sign in to comment.