From 6834a8d805639e1b3796d0117e2643e3f555e5cf Mon Sep 17 00:00:00 2001 From: fdai6040 Date: Tue, 7 Feb 2023 10:41:06 +0100 Subject: [PATCH] Tic Tac Toe created method if player 0 wins --- src/main/java/src/TicTacToeGame.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/src/TicTacToeGame.java b/src/main/java/src/TicTacToeGame.java index 1216348..2108c2f 100644 --- a/src/main/java/src/TicTacToeGame.java +++ b/src/main/java/src/TicTacToeGame.java @@ -116,6 +116,17 @@ public class TicTacToeGame implements ActionListener { { 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