Browse Source

refactoring: renamed player2button to player2fieldButton

master
TRC9696 2 years ago
parent
commit
4f40e1f8ab
  1. 46
      src/main/java/game/StartTicTacToeGame.java

46
src/main/java/game/StartTicTacToeGame.java

@ -23,11 +23,11 @@ public class StartTicTacToeGame implements ActionListener{
player1fieldButton7Pressed, player1fieldButton8Pressed, player1fieldButton7Pressed, player1fieldButton8Pressed,
player1fieldButton9Pressed = false; player1fieldButton9Pressed = false;
boolean player2buttonPressed, player2button2Pressed,
player2button3Pressed, player2button4Pressed,
player2button5Pressed, player2button6Pressed,
player2button7Pressed, player2button8Pressed,
player2button9Pressed = false;
boolean player2fieldButtonPressed, player2fieldButton2Pressed,
player2fieldButton3Pressed, player2fieldButton4Pressed,
player2fieldButton5Pressed, player2fieldButton6Pressed,
player2fieldButton7Pressed, player2fieldButton8Pressed,
player2fieldButton9Pressed = false;
boolean player1Turn = true; boolean player1Turn = true;
boolean player2Turn = false; boolean player2Turn = false;
@ -149,7 +149,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton.setFont(new Font("arial", Font.PLAIN, 30));
fieldButton.setEnabled(false); fieldButton.setEnabled(false);
player1Turn(); player1Turn();
player2buttonPressed = true;
player2fieldButtonPressed = true;
check(); check();
} }
} }
@ -169,7 +169,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton2.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton2.setFont(new Font("arial", Font.PLAIN, 30));
fieldButton2.setEnabled(false); fieldButton2.setEnabled(false);
player1Turn(); player1Turn();
player2button2Pressed = true;
player2fieldButton2Pressed = true;
check(); check();
} }
} }
@ -189,7 +189,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton3.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton3.setFont(new Font("arial", Font.PLAIN, 30));
player1Turn(); player1Turn();
fieldButton3.setEnabled(false); fieldButton3.setEnabled(false);
player2button3Pressed = true;
player2fieldButton3Pressed = true;
check(); check();
} }
} }
@ -209,7 +209,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton4.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton4.setFont(new Font("arial", Font.PLAIN, 30));
player1Turn(); player1Turn();
fieldButton4.setEnabled(false); fieldButton4.setEnabled(false);
player2button4Pressed = true;
player2fieldButton4Pressed = true;
check(); check();
} }
} }
@ -229,7 +229,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton5.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton5.setFont(new Font("arial", Font.PLAIN, 30));
player1Turn(); player1Turn();
fieldButton5.setEnabled(false); fieldButton5.setEnabled(false);
player2button5Pressed = true;
player2fieldButton5Pressed = true;
check(); check();
} }
} }
@ -249,7 +249,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton6.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton6.setFont(new Font("arial", Font.PLAIN, 30));
player1Turn(); player1Turn();
fieldButton6.setEnabled(false); fieldButton6.setEnabled(false);
player2button6Pressed = true;
player2fieldButton6Pressed = true;
check(); check();
} }
} }
@ -269,7 +269,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton7.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton7.setFont(new Font("arial", Font.PLAIN, 30));
player1Turn(); player1Turn();
fieldButton7.setEnabled(false); fieldButton7.setEnabled(false);
player2button7Pressed = true;
player2fieldButton7Pressed = true;
check(); check();
} }
} }
@ -289,7 +289,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton8.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton8.setFont(new Font("arial", Font.PLAIN, 30));
player1Turn(); player1Turn();
fieldButton8.setEnabled(false); fieldButton8.setEnabled(false);
player2button8Pressed = true;
player2fieldButton8Pressed = true;
check(); check();
} }
} }
@ -309,7 +309,7 @@ public class StartTicTacToeGame implements ActionListener{
fieldButton9.setFont(new Font("arial", Font.PLAIN, 30)); fieldButton9.setFont(new Font("arial", Font.PLAIN, 30));
fieldButton9.setEnabled(false); fieldButton9.setEnabled(false);
player1Turn(); player1Turn();
player2button9Pressed = true;
player2fieldButton9Pressed = true;
check(); check();
} }
} }
@ -378,31 +378,31 @@ public class StartTicTacToeGame implements ActionListener{
player1Won(); player1Won();
} }
if(player2buttonPressed && player2button2Pressed && player2button3Pressed) {
if(player2fieldButtonPressed && player2fieldButton2Pressed && player2fieldButton3Pressed) {
player2Won(); player2Won();
} }
else if(player2button4Pressed && player2button5Pressed && player2button6Pressed) {
else if(player2fieldButton4Pressed && player2fieldButton5Pressed && player2fieldButton6Pressed) {
player2Won(); player2Won();
} }
else if(player2button7Pressed && player2button8Pressed && player2button9Pressed) {
else if(player2fieldButton7Pressed && player2fieldButton8Pressed && player2fieldButton9Pressed) {
player2Won(); player2Won();
} }
else if(player2buttonPressed && player2button5Pressed && player2button6Pressed) {
else if(player2fieldButtonPressed && player2fieldButton5Pressed && player2fieldButton6Pressed) {
player2Won(); player2Won();
} }
else if(player2buttonPressed && player2button4Pressed && player2button7Pressed) {
else if(player2fieldButtonPressed && player2fieldButton4Pressed && player2fieldButton7Pressed) {
player2Won(); player2Won();
} }
else if(player2button2Pressed && player2button5Pressed && player2button8Pressed) {
else if(player2fieldButton2Pressed && player2fieldButton5Pressed && player2fieldButton8Pressed) {
player2Won(); player2Won();
} }
else if(player2button3Pressed && player2button6Pressed && player2button9Pressed) {
else if(player2fieldButton3Pressed && player2fieldButton6Pressed && player2fieldButton9Pressed) {
player2Won(); player2Won();
} }
else if(player2buttonPressed && player2button5Pressed && player2button9Pressed) {
else if(player2fieldButtonPressed && player2fieldButton5Pressed && player2fieldButton9Pressed) {
player2Won(); player2Won();
} }
else if(player2button3Pressed && player2button5Pressed && player2button7Pressed) {
else if(player2fieldButton3Pressed && player2fieldButton5Pressed && player2fieldButton7Pressed) {
player2Won(); player2Won();
} }
} }
Loading…
Cancel
Save