diff --git a/src/main/java/src/TicTacToeGame.java b/src/main/java/src/TicTacToeGame.java index 8a6295f..58ada26 100644 --- a/src/main/java/src/TicTacToeGame.java +++ b/src/main/java/src/TicTacToeGame.java @@ -55,7 +55,7 @@ public class TicTacToeGame implements ActionListener { startGame(); } - // Creating method to start the game and decide the chance + // Creating method to start the game public void startGame() { try @@ -81,8 +81,21 @@ public class TicTacToeGame implements ActionListener { } } + //creating method for checking winner + public void chek(){ + if ((bton[0].getText() == "X") && (bton[1].getText() == "X") && (bton[2].getText() == "X")) + { + xWin(0, 1, 2); + } + else if ((bton[0].getText() == "X") && (bton[4].getText() == "X") && (bton[8].getText() == "X")) + { + xWin(0, 4, 8); + } + } + private void xWin(int i, int i1, int i2) { + } //Method for performing action after every turn @@ -112,6 +125,7 @@ public class TicTacToeGame implements ActionListener { pl1_chance = true; textfield.setText("X turn"); chance_flag++; + chek(); } }