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
Extract winning_player method
  • Loading branch information
edgenard committed Apr 2, 2018
1 parent 37bb1a1 commit 91764b5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tic-tac-toe/tic_tac_toe.rb
Expand Up @@ -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.

Copy link
@medwards1771

medwards1771 Apr 3, 2018

Contributor

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)
Expand Down

0 comments on commit 91764b5

Please sign in to comment.