Question: package game 2 0 4 8 logic; import game 2 0 4 8 rendering.Board; import game 2 0 4 8 rendering.Side; import game 2 0
package gamelogic;
import gamerendering.Board;
import gamerendering.Side;
import gamerendering.Tile;
import java.util.Formatter;
The state of a game of
@author P N Hilfinger Josh Hug
public class Model
Current contents of the board.
private final Board board;
Current score.
private int score;
Coordinate System: column x row y of the board where x
y is the lowerleft corner of the board will correspond
to board.tilex y Be careful!
Largest piece value.
public static final int MAXPIECE ;
A new game on a board of size SIZE with no pieces
and score
public Modelint size
board new Boardsize;
score ;
A new game where RAWVALUES contain the values of the tiles
if null VALUES is indexed by x y with corresponding
to the bottomleft corner. Used for testing purposes.
public Modelint rawValues, int score
board new BoardrawValues;
this.score score;
Return the current Tile at x y where x size
y size Returns null if there is no tile there.
Used for testing.
public Tile tileint x int y
return board.tilex y;
Return the number of squares on one side of the board.
public int size
return board.size;
Return the current score.
public int score
return score;
Clear the board to empty and reset the score.
public void clear
score ;
board.clear;
Add TILE to the board. There must be no Tile currently at the
same position.
public void addTileTile tile
board.addTiletile;
Return true iff the game is over there are no moves, or
there is a tile with value on the board
public boolean gameOver
return maxTileExistsatLeastOneMoveExists;
Returns this Model's board.
public Board getBoard
return board;
Returns true if at least one space on the Board is empty.
Empty spaces are stored as null.
public boolean emptySpaceExists
TODO: Task CODE HERE
return false;
do the code for me
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
