/** * Write a description of class FifteenPuzzle here. * * @author (your name) * @version (a version number or a date) */ import java.awt.event.*; import java.awt.Color; public class FifteenPuzzle { private int[][] grid; // the current positions of the tiles and space, denoted by 0..15 private int xspace; // xspace,yspace are the current coordinates of the space private int yspace; private SimpleCanvas sc; // the canvas for display private final int size = 4; // the number of tiles across and down private final int tilesize = 50; // the size of a tile private final int gridsize = size * tilesize; // the size of the grid private int[][] goal = {{1, 5,9,13}, {2,6,10,14}, {3,7,11,15}, {4,8,12, 0}}; // these two are public so that they can be used in BlueJ public static int[][] close = {{1, 5,9,13}, {2,6,10,14}, {3,7,11, 0}, {4,8,12,15}}; public static int[][] example = {{5,11,14,0}, {9,3,13, 7}, {2,8,10,12}, {4,1,15, 6}}; // this constructor sets up the grid as initialGrid and displays it on the canvas // (plus it initialises the other instance variables) public FifteenPuzzle (int[][] initialGrid) { // TODO } // this constructor sets up the grid as goal, // then it makes random moves to set up the puzzle and displays it on the canvas // (plus it initialises the other instance variables) public FifteenPuzzle () { // TODO } // returns true iff x,y is adjacent to the space private boolean legalClick(int x, int y) { // TODO return false; } // returns true iff the puzzle is finished private boolean finished() { // TODO return false; } // moves the tile at x,y into the space, if it is adjacent, and re-draws the grid; o/w do nothing public void moveTile (int x, int y) { // TODO } // draws the current grid on the canvas private void drawGrid() { // TODO } // draws the tile at x,y in colour c at the appropriate spot on the canvas private void drawTile(int x, int y, Color c) { //TODO } }