Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 Fill in this function.
return false;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started