Permalink
Browse files

Extract winning_player method

  • Loading branch information...
edgenard committed Apr 2, 2018
1 parent 37bb1a1 commit 91764b593f2e8a728a4fcfa8f6ba7ac31252188e
Showing with 7 additions and 7 deletions.
  1. +7 −7 tic-tac-toe/tic_tac_toe.rb
@@ -27,18 +27,18 @@ def winning_move?(square, player)

def winner
square = 0
if board[square] != '-' && board[square] == board[square + 1] && board[square + 1] == board[square + 2]
return board[square]
end
return winning_player(square) if winning_player(square)
square = 3
if board[square] != '-' && board[square] == board[square + 1] && board[square + 1] == board[square + 2]
return board[square]
end
return winning_player(square) if winning_player(square)
square = 6
return winning_player(square) if winning_player(square)
return '-'
end

def winning_player(square)

This comment has been minimized.

@medwards1771

medwards1771 Apr 3, 2018

Collaborator

You introduce a new method here, #winning_player. Where did this method come from?

if board[square] != '-' && board[square] == board[square + 1] && board[square + 1] == board[square + 2]
return board[square]
end
return '-'
end

def square_unoccupied?(square)

0 comments on commit 91764b5

Please sign in to comment.