|
@ -157,6 +157,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button.setEnabled(false); |
|
|
button.setEnabled(false); |
|
|
player1buttonPressed = true; |
|
|
player1buttonPressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button.setForeground(Color.black); |
|
|
button.setForeground(Color.black); |
|
@ -165,6 +166,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
button.setEnabled(false); |
|
|
button.setEnabled(false); |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
player2buttonPressed = true; |
|
|
player2buttonPressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button2) { |
|
|
else if(e.getSource() == button2) { |
|
@ -175,6 +177,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button2.setEnabled(false); |
|
|
button2.setEnabled(false); |
|
|
player1button2Pressed = true; |
|
|
player1button2Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button2.setForeground(Color.black); |
|
|
button2.setForeground(Color.black); |
|
@ -183,6 +186,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
button2.setEnabled(false); |
|
|
button2.setEnabled(false); |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
player2button2Pressed = true; |
|
|
player2button2Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button3) { |
|
|
else if(e.getSource() == button3) { |
|
@ -193,6 +197,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button3.setEnabled(false); |
|
|
button3.setEnabled(false); |
|
|
player1button3Pressed = true; |
|
|
player1button3Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button3.setForeground(Color.black); |
|
|
button3.setForeground(Color.black); |
|
@ -201,6 +206,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
button3.setEnabled(false); |
|
|
button3.setEnabled(false); |
|
|
player2button3Pressed = true; |
|
|
player2button3Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button4) { |
|
|
else if(e.getSource() == button4) { |
|
@ -211,6 +217,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button4.setEnabled(false); |
|
|
button4.setEnabled(false); |
|
|
player1button4Pressed = true; |
|
|
player1button4Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button4.setForeground(Color.black); |
|
|
button4.setForeground(Color.black); |
|
@ -219,6 +226,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
button4.setEnabled(false); |
|
|
button4.setEnabled(false); |
|
|
player2button4Pressed = true; |
|
|
player2button4Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button5) { |
|
|
else if(e.getSource() == button5) { |
|
@ -229,6 +237,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button5.setEnabled(false); |
|
|
button5.setEnabled(false); |
|
|
player1button5Pressed = true; |
|
|
player1button5Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button5.setForeground(Color.black); |
|
|
button5.setForeground(Color.black); |
|
@ -237,6 +246,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
button5.setEnabled(false); |
|
|
button5.setEnabled(false); |
|
|
player2button5Pressed = true; |
|
|
player2button5Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button6) { |
|
|
else if(e.getSource() == button6) { |
|
@ -247,6 +257,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button6.setEnabled(false); |
|
|
button6.setEnabled(false); |
|
|
player1button6Pressed = true; |
|
|
player1button6Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button6.setForeground(Color.black); |
|
|
button6.setForeground(Color.black); |
|
@ -255,6 +266,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
button6.setEnabled(false); |
|
|
button6.setEnabled(false); |
|
|
player2button6Pressed = true; |
|
|
player2button6Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button7) { |
|
|
else if(e.getSource() == button7) { |
|
@ -265,6 +277,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button7.setEnabled(false); |
|
|
button7.setEnabled(false); |
|
|
player1button7Pressed = true; |
|
|
player1button7Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button7.setForeground(Color.black); |
|
|
button7.setForeground(Color.black); |
|
@ -273,6 +286,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
button7.setEnabled(false); |
|
|
button7.setEnabled(false); |
|
|
player2button7Pressed = true; |
|
|
player2button7Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button8) { |
|
|
else if(e.getSource() == button8) { |
|
@ -283,6 +297,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button8.setEnabled(false); |
|
|
button8.setEnabled(false); |
|
|
player1button8Pressed = true; |
|
|
player1button8Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button8.setForeground(Color.black); |
|
|
button8.setForeground(Color.black); |
|
@ -291,6 +306,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
button8.setEnabled(false); |
|
|
button8.setEnabled(false); |
|
|
player2button8Pressed = true; |
|
|
player2button8Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(e.getSource() == button9) { |
|
|
else if(e.getSource() == button9) { |
|
@ -301,6 +317,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
player2Turn(); |
|
|
player2Turn(); |
|
|
button9.setEnabled(false); |
|
|
button9.setEnabled(false); |
|
|
player1button9Pressed = true; |
|
|
player1button9Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
button9.setForeground(Color.black); |
|
|
button9.setForeground(Color.black); |
|
@ -309,6 +326,7 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
button9.setEnabled(false); |
|
|
button9.setEnabled(false); |
|
|
player1Turn(); |
|
|
player1Turn(); |
|
|
player2button9Pressed = true; |
|
|
player2button9Pressed = true; |
|
|
|
|
|
check(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -346,4 +364,62 @@ public class StartTicTacToeGame implements ActionListener{ |
|
|
//zurück button |
|
|
//zurück button |
|
|
backButton.setVisible(true); |
|
|
backButton.setVisible(true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void check() { |
|
|
|
|
|
if(player1buttonPressed && player1button2Pressed && player1button3Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1button4Pressed && player1button5Pressed && player1button6Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1button7Pressed && player1button8Pressed && player1button9Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1buttonPressed && player1button5Pressed && player1button6Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1buttonPressed && player1button4Pressed && player1button7Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1button2Pressed && player1button5Pressed && player1button8Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1button3Pressed && player1button6Pressed && player1button9Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1buttonPressed && player1button5Pressed && player1button9Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player1button3Pressed && player1button5Pressed && player1button7Pressed) { |
|
|
|
|
|
player1Won(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(player2buttonPressed && player2button2Pressed && player2button3Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2button4Pressed && player2button5Pressed && player2button6Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2button7Pressed && player2button8Pressed && player2button9Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2buttonPressed && player2button5Pressed && player2button6Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2buttonPressed && player2button4Pressed && player2button7Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2button2Pressed && player2button5Pressed && player2button8Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2button3Pressed && player2button6Pressed && player2button9Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2buttonPressed && player2button5Pressed && player2button9Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(player2button3Pressed && player2button5Pressed && player2button7Pressed) { |
|
|
|
|
|
player2Won(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |