|
|
@ -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(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|