Site Loader
Order Essay
111 Town Square Pl, Jersey City, NJ 07310, U.S.
111 Town Square Pl, Jersey City, NJ 07310, U.S.

package game;

public class GameModel {

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

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

x

Hi!
I'm Elizabeth!

Would you like to get a custom essay? How about receiving a customized one?

Check it out