Permalink
Browse files

Add position occupied method

  • Loading branch information...
edgenard committed Apr 3, 2018
1 parent 194ce3a commit 4ccb07335bfd624be55883f0e64cbf623fe2df75
Showing with 5 additions and 1 deletion.
  1. +5 −1 tic-tac-toe/tic_tac_toe.rb
@@ -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.