Skip to content
Snippets Groups Projects
Commit a5cdffce authored by Jan's avatar Jan Committed by Nick
Browse files

updated Actor interface

parent fdb47d92
No related branches found
No related tags found
1 merge request!2Fehler fix
......@@ -8,4 +8,19 @@ public interface Actor {
public char getSymbol();
public void setSymbol(char symbol);
// Methode für Spieler mit Koordinaten
default boolean makeMove(Board board, int x, int y) {
return board.placeToken(x, y, symbol);
}
// Methode für Gegner (Zufallsgenerator)
default boolean makeMove(Board board) {
Random random = new Random();
int x, y;
do {
x = random.nextInt(3);
y = random.nextInt(3);
} while (!board.placeToken(x, y, symbol));
return true;
}
}
......@@ -18,16 +18,5 @@ public class Enemy implements Actor {
this.symbol = symbol;
}
// Methode, um den nächsten Zug des Akteurs zu machen
public boolean makeMove(Board board) {
Random random = new Random();
int x;
int y;
do {
x = random.nextInt(3);
y = random.nextInt(3);
} while (!board.placeToken(x, y, symbol));
return true;
}
}
......@@ -18,8 +18,4 @@ public class Player implements Actor {
// Methode, um den nächsten Zug des Akteurs zu machen
public boolean makeMove(Board board, int x, int y) {
return board.placeToken(x, y, symbol);
}
}
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