Skip to content
Snippets Groups Projects
Commit 2a366dfe authored by Nick's avatar Nick
Browse files

winning bool geändert

parent 28c2e692
No related branches found
No related tags found
1 merge request!2Fehler fix
......@@ -93,16 +93,18 @@ public class SceneController {
int row = GridPane.getRowIndex(pressedButton); // Zeilen-Koordinate
int col = GridPane.getColumnIndex(pressedButton); // Spalten-Koordinate
//over();
if(buttonText.equals(" ") && playerTurn == 1) {
// Setze X
pressedButton.setText("X");
player.makeMove(board, col, row);
//over();
over();
aiTurn();
over();
board.printBoard();
}
}
......
......@@ -10,7 +10,7 @@ public interface Actor {
// Methode für Spieler mit Koordinaten
default boolean makeMove(Board board, int x, int y) {
return board.placeToken(x, y, symbol);
return board.placeToken(x, y, 'X');
}
// Methode für Gegner (Zufallsgenerator)
......@@ -20,7 +20,7 @@ public interface Actor {
do {
x = random.nextInt(3);
y = random.nextInt(3);
} while (!board.placeToken(x, y, symbol));
} while (!board.placeToken(x, y, 'O'));
int[] coordinates = {x, y};
return coordinates;
}
......
......@@ -8,7 +8,7 @@ public class Board{
char[][] board = new char[3][3];
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
board[i][j] = '#';
board[j][i] = '#';
}
}
gameboard = board;
......@@ -31,7 +31,7 @@ public class Board{
String output = "";
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
output = output + gameboard[i][j];
output = output + gameboard[j][i];
}
output = output + "\n";
}
......@@ -53,7 +53,7 @@ public class Board{
this.setWinner(gameboard[i][0]);
return true;
}
if((gameboard[0][i] == gameboard[1][i]) && (gameboard[i][0] != '#') && (gameboard[0][i] == gameboard[2][i]) ) {
if((gameboard[0][i] == gameboard[1][i]) && (gameboard[0][i] != '#') && (gameboard[0][i] == gameboard[2][i]) ) {
this.setWinner(gameboard[i][0]);
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment