|
@ -114,6 +114,13 @@ public class GameLogic implements ActionListener { |
|
|
this.currentPlayer = this.currentPlayer == PLAYER_1 ? PLAYER_2 : PLAYER_1; |
|
|
this.currentPlayer = this.currentPlayer == PLAYER_1 ? PLAYER_2 : PLAYER_1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void resetBoard() { |
|
|
|
|
|
for (int i = 0; i < this.board.length; i++) { |
|
|
|
|
|
for (int j = 0; j < this.board.length; j++) { |
|
|
|
|
|
this.board[i][j] = '-'; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public JPanel generateGUI() { |
|
|
public JPanel generateGUI() { |
|
|
this.fields = new JButton[this.board.length][this.board.length]; |
|
|
this.fields = new JButton[this.board.length][this.board.length]; |
|
@ -142,7 +149,18 @@ public class GameLogic implements ActionListener { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
JOptionPane.showMessageDialog(contentPanel, "Spieler " + this.currentPlayer + " hat gewonnen."); |
|
|
JOptionPane.showMessageDialog(contentPanel, "Spieler " + this.currentPlayer + " hat gewonnen."); |
|
|
System.exit(0); |
|
|
|
|
|
|
|
|
this.resetGUI(); |
|
|
|
|
|
} |
|
|
|
|
|
this.switchPlayer(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void resetGUI() { |
|
|
|
|
|
for (int i = 0; i < this.fields.length; i++) { |
|
|
|
|
|
for (int j = 0; j < this.fields.length; j++) { |
|
|
|
|
|
this.resetBoard(); |
|
|
|
|
|
this.fields[i][j].setText(""); |
|
|
|
|
|
this.fields[i][j].setEnabled(true); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
this.switchPlayer(); |
|
|
this.switchPlayer(); |
|
|
} |
|
|
} |
|
|