Browse Source

Tic Tac Toe creating method for checking winner

remotes/origin/develop
fdai6040 2 years ago
parent
commit
63972dbe1f
  1. 16
      src/main/java/src/TicTacToeGame.java

16
src/main/java/src/TicTacToeGame.java

@ -55,7 +55,7 @@ public class TicTacToeGame implements ActionListener {
startGame(); startGame();
} }
// Creating method to start the game and decide the chance
// Creating method to start the game
public void startGame() public void startGame()
{ {
try 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 //Method for performing action after every turn
@ -112,6 +125,7 @@ public class TicTacToeGame implements ActionListener {
pl1_chance = true; pl1_chance = true;
textfield.setText("X turn"); textfield.setText("X turn");
chance_flag++; chance_flag++;
chek();
} }
} }

Loading…
Cancel
Save