|
@ -17,11 +17,11 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
static JButton fieldButton,fieldButton2,fieldButton3,fieldButton4, |
|
|
static JButton fieldButton,fieldButton2,fieldButton3,fieldButton4, |
|
|
fieldButton5,fieldButton6,fieldButton7,fieldButton8,fieldButton9,backButton = new JButton(); |
|
|
fieldButton5,fieldButton6,fieldButton7,fieldButton8,fieldButton9,backButton = new JButton(); |
|
|
|
|
|
|
|
|
boolean player1buttonPressed, player1button2Pressed, |
|
|
|
|
|
player1button3Pressed, player1button4Pressed, |
|
|
|
|
|
player1button5Pressed, player1button6Pressed, |
|
|
|
|
|
player1button7Pressed, player1button8Pressed, |
|
|
|
|
|
player1button9Pressed = false; |
|
|
|
|
|
|
|
|
boolean player1fieldButtonPressed, player1fieldButton2Pressed, |
|
|
|
|
|
player1fieldButton3Pressed, player1fieldButton4Pressed, |
|
|
|
|
|
player1fieldButton5Pressed, player1fieldButton6Pressed, |
|
|
|
|
|
player1fieldButton7Pressed, player1fieldButton8Pressed, |
|
|
|
|
|
player1fieldButton9Pressed = false; |
|
|
|
|
|
|
|
|
boolean player2buttonPressed, player2button2Pressed, |
|
|
boolean player2buttonPressed, player2button2Pressed, |
|
|
player2button3Pressed, player2button4Pressed, |
|
|
player2button3Pressed, player2button4Pressed, |
|
@ -140,7 +140,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton.setEnabled(false); |
|
|
fieldButton.setEnabled(false); |
|
|
player1buttonPressed = true; |
|
|
|
|
|
|
|
|
player1fieldButtonPressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -160,7 +160,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton2.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton2.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton2.setEnabled(false); |
|
|
fieldButton2.setEnabled(false); |
|
|
player1button2Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton2Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -180,7 +180,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton3.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton3.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton3.setEnabled(false); |
|
|
fieldButton3.setEnabled(false); |
|
|
player1button3Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton3Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -200,7 +200,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton4.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton4.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton4.setEnabled(false); |
|
|
fieldButton4.setEnabled(false); |
|
|
player1button4Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton4Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -220,7 +220,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton5.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton5.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton5.setEnabled(false); |
|
|
fieldButton5.setEnabled(false); |
|
|
player1button5Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton5Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -240,7 +240,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton6.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton6.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton6.setEnabled(false); |
|
|
fieldButton6.setEnabled(false); |
|
|
player1button6Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton6Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -260,7 +260,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton7.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton7.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton7.setEnabled(false); |
|
|
fieldButton7.setEnabled(false); |
|
|
player1button7Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton7Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -280,7 +280,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton8.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton8.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton8.setEnabled(false); |
|
|
fieldButton8.setEnabled(false); |
|
|
player1button8Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton8Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -300,7 +300,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
fieldButton9.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
fieldButton9.setFont(new Font("arial", Font.PLAIN, 30)); |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
fieldButton9.setEnabled(false); |
|
|
fieldButton9.setEnabled(false); |
|
|
player1button9Pressed = true; |
|
|
|
|
|
|
|
|
player1fieldButton9Pressed = true; |
|
|
check(); |
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -350,31 +350,31 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void check() { |
|
|
public void check() { |
|
|
if(player1buttonPressed && player1button2Pressed && player1button3Pressed) { |
|
|
|
|
|
|
|
|
if(player1fieldButtonPressed && player1fieldButton2Pressed && player1fieldButton3Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1button4Pressed && player1button5Pressed && player1button6Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButton4Pressed && player1fieldButton5Pressed && player1fieldButton6Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1button7Pressed && player1button8Pressed && player1button9Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButton7Pressed && player1fieldButton8Pressed && player1fieldButton9Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1buttonPressed && player1button5Pressed && player1button6Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButtonPressed && player1fieldButton5Pressed && player1fieldButton6Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1buttonPressed && player1button4Pressed && player1button7Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButtonPressed && player1fieldButton4Pressed && player1fieldButton7Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1button2Pressed && player1button5Pressed && player1button8Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButton2Pressed && player1fieldButton5Pressed && player1fieldButton8Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1button3Pressed && player1button6Pressed && player1button9Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButton3Pressed && player1fieldButton6Pressed && player1fieldButton9Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1buttonPressed && player1button5Pressed && player1button9Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButtonPressed && player1fieldButton5Pressed && player1fieldButton9Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
else if(player1button3Pressed && player1button5Pressed && player1button7Pressed) { |
|
|
|
|
|
|
|
|
else if(player1fieldButton3Pressed && player1fieldButton5Pressed && player1fieldButton7Pressed) { |
|
|
player1Won(); |
|
|
player1Won(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|