Browse Source

Tic Tac Toe created method if player 0 wins

remotes/origin/develop
fdai6040 2 years ago
parent
commit
6834a8d805
  1. 11
      src/main/java/src/TicTacToeGame.java

11
src/main/java/src/TicTacToeGame.java

@ -116,6 +116,17 @@ public class TicTacToeGame implements ActionListener {
{ {
xWin(6, 7, 8); xWin(6, 7, 8);
} }
else if ((bton[0].getText() == "O") && (bton[1].getText() == "O") && (bton[2].getText() == "O"))
{
oWin(0, 1, 2);
}
}
//method if player 0 wins
private void oWin(int i, int i1, int i2) {
bton[i].setBackground(Color.PINK);
bton[i1].setBackground(Color.PINK);
bton[i2].setBackground(Color.PINK);
} }
//method if player X wins //method if player X wins

Loading…
Cancel
Save