You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
854 B

package Game;
import Game.TicTacToe.Board;
public class Tictactoe extends Game {
private String input;
private Board currentBoard;
private boolean crossTurn;
public Tictactoe() {
init();
}
private void init() {
crossTurn = true;
currentBoard = new Board();
}
@Override
public void update(String input) {
outputBuffer.clear();
boolean validTurn = currentBoard.setCellState(Integer.parseInt(input), crossTurn);
outputBuffer.addAll(currentBoard.getOutputBoard());
if(validTurn) {
switchTurn();
} else {
outputBuffer.add("Invalid Turn!");
}
outputBuffer.add((crossTurn?"Cross":"Circle") + " it´s your Turn, please choose a Cell:");
}
public void switchTurn() {
crossTurn = !crossTurn;
}
}