|
|
@ -5,6 +5,7 @@ import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
public class GameLogic implements ActionListener { |
|
|
@ -138,7 +139,20 @@ public class GameLogic implements ActionListener { |
|
|
|
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.fields[i][j].setText("clicked"); |
|
|
|
this.setField(i, j, currentPlayer); |
|
|
|
this.fields[i][j].setText("" + this.getCurrentPlayer()); |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
this.switchPlayer(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|