Class PuzzleBoard

java.lang.Object
   |
   +----PuzzleBoard

public class PuzzleBoard
extends Object

Constructor Index

 o PuzzleBoard()
The default constructor-- sets up the board of puzzlePieces

Method Index

 o draw()
Draws the board and the "Scramble" box.
 o isScramble(Point)
Given a point, checks if it's inside the "Scramble" box.
 o move(Point)
Takes the point p and checks if it is within the "Scramble" box.
 o privateMove(int, int)
Takes the indices and checks for the place to move the piece.
 o Scramble()
Scrambles the pieces by calling privateMove a 1000 times with randomly generated indices.

Constructors

 o PuzzleBoard
 public PuzzleBoard()
The default constructor-- sets up the board of puzzlePieces

Methods

 o move
 public void move(Point p)
Takes the point p and checks if it is within the "Scramble" box. If so, it calls the private method Scramble(). If not, it determines which square has been clicked (in terms of the indices of the array) and calls a private method privateMove with the indices.

Parameters:
p - the location of the last mouse click
 o draw
 public void draw()
Draws the board and the "Scramble" box. The puzzle pieces are drawn by calling the draw method in PuzzlePiece.

 o isScramble
 private boolean isScramble(Point p)
Given a point, checks if it's inside the "Scramble" box.

Parameters:
p - the point the user clicked.
Returns:
true if p is in the box, false otherwise.
 o Scramble
 private void Scramble()
Scrambles the pieces by calling privateMove a 1000 times with randomly generated indices. (This is called from move().).

 o privateMove
 private void privateMove(int i,
                          int j)
Takes the indices and checks for the place to move the piece. This is where all the work takes place. After finding the move, the piece is moved to it's new position in the array, and it's position on the board is updated using the move method in PuzzlePiece.

Parameters:
i - the first index, ranges from 0 to 3
j - the second index, ranges from 0 to 3