|
@ -134,28 +134,31 @@ public class GameLogic implements ActionListener { |
|
|
return this.fields[column][row]; |
|
|
return this.fields[column][row]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
for (int i = 0; i < this.fields.length; i++) { |
|
|
|
|
|
for (int j = 0; j < this.fields[0].length; j++) { |
|
|
|
|
|
if (e.getSource() == this.fields[i][j]) { |
|
|
|
|
|
this.setField(i, j, currentPlayer); |
|
|
|
|
|
this.fields[i][j].setText("" + this.getCurrentPlayer()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateGUI() { |
|
|
if (this.checkEndOfGame()) { |
|
|
if (this.checkEndOfGame()) { |
|
|
JOptionPane.showMessageDialog(contentPanel, "Spieler " + this.currentPlayer + " hat gewonnen."); |
|
|
|
|
|
for (int k = 0; k < this.fields.length; k++) { |
|
|
|
|
|
for (int l = 0; l < this.fields.length; l++) { |
|
|
|
|
|
this.fields[k][l].setEnabled(false); |
|
|
|
|
|
|
|
|
for (int i = 0; i < this.fields.length; i++) { |
|
|
|
|
|
for (int j = 0; j < this.fields.length; j++) { |
|
|
|
|
|
this.fields[i][j].setEnabled(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
JOptionPane.showMessageDialog(contentPanel, "Spieler " + this.currentPlayer + " hat gewonnen."); |
|
|
System.exit(0); |
|
|
System.exit(0); |
|
|
} |
|
|
} |
|
|
this.switchPlayer(); |
|
|
this.switchPlayer(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
for (int i = 0; i < this.fields.length; i++) { |
|
|
|
|
|
for (int j = 0; j < this.fields[0].length; j++) { |
|
|
|
|
|
if (e.getSource() == this.fields[i][j]) { |
|
|
|
|
|
this.setField(i, j, currentPlayer); |
|
|
|
|
|
this.fields[i][j].setText("" + this.getCurrentPlayer()); |
|
|
|
|
|
updateGUI(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |