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 game2048logic;
import game2048rendering.Board;
import game2048rendering.Side;
import game2048rendering.Tile;
import java.util.Formatter;
/** The state of a game of 2048.
* @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 =0,
* y =0 is the lower-left corner of the board) will correspond
* to board.tile(x, y). Be careful!
*/
/** Largest piece value. */
public static final int MAX_PIECE =2048;
/** A new 2048 game on a board of size SIZE with no pieces
* and score 0.*/
public Model(int size){
board = new Board(size);
score =0;
}
/** A new 2048 game where RAWVALUES contain the values of the tiles
*(0 if null). VALUES is indexed by (x, y) with (0,0) corresponding
* to the bottom-left corner. Used for testing purposes. */
public Model(int[][] rawValues, int score){
board = new Board(rawValues);
this.score = score;
}
/** Return the current Tile at (x, y), where 0<= x < size(),
*0<= y < size(). Returns null if there is no tile there.
* Used for testing. */
public Tile tile(int x, int y){
return board.tile(x, 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 =0;
board.clear();
}
/** Add TILE to the board. There must be no Tile currently at the
* same position. */
public void addTile(Tile tile){
board.addTile(tile);
}
/** Return true iff the game is over (there are no moves, or
* there is a tile with value 2048 on the board).*/
public boolean gameOver(){
return maxTileExists()||!atLeastOneMoveExists();
}
/** 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 2.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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!