Site Loader

package game;

public class GameModel {

private int board;
private boolean gameOver;
private boolean winnerCalled;
private int winner = Positions.CONTINUE;

public GameModel() {
board = new int55;
}

public void select(Locations square) {

int row = square.getRow();
int col = square.getColumn();

if (!gameOver && boardrowcol == 0 &&
row >= 0 && row = 0 && col < 5) {
boardrowcol = Positions.X;
Positions response = new Positions(board, true, square);
Locations move = response.getMove();
if (move != null) {
boardmove.getRow()move.getColumn() = Positions.O;
}
}

int evaluation = Positions.eval(board);
if (evaluation != Positions.CONTINUE) {
winner = evaluation;
gameOver = true;
}
}

public String getLabel(Locations square) {
int row = square.getRow();
int col = square.getColumn();
int val = boardrowcol;

switch (val) {
case 0:
return "";
case Positions.X:
return "X";
case Positions.O:
return "O";
default:
throw new IllegalStateException(
"The board has the invalid entry " + val + ".");
}
}

public boolean gameIsOver() {
return gameOver;
}

public boolean getWinnerCalled() {
return winnerCalled;
}

public int getWinner() {
winnerCalled = true;
return winner;
}
}

Post Author: admin