agentland.games.boggle
Class Board

java.lang.Object
  |
  +--agentland.games.boggle.Board
All Implemented Interfaces:
Serializable

public class Board
extends Object
implements Serializable

Represents the abstract Boggle board and its current state. A Boggle Board has 16 6-sided dice with letters, and a grid such that one letter faces up at any given time. Letters are distributed randomly.

See Also:
Serializable, Serialized Form

Constructor Summary
Board()
          Creates a new default Board instance.
Board(int rows, int cols)
          Creates a new Board instance.
Board(int rows, int cols, Collection letters)
          Creates a new Board instance.
 
Method Summary
 int columns()
          Get number of columns in this instantiation of Board.
 String getLetter(Coordinate coord)
          Tell which letter is visible at the given board position.
 String getLetter(int x, int y)
          Tell which letter is visible at the given board position.
 Collection letters()
          Get the Collection of letters that the board has stored in its alphabet.
 int rows()
          Get number of rows in this instantiation of Board.
 void shake()
          This method does just what you might think...Scramble the board so that the getLetter methods will return different values than before shaking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Board

public Board()
Creates a new default Board instance. By default the size of the board is 4x4 and the letters used are A-Z, except that Q is replaced by Qu and treated as a single letter.

Board

public Board(int rows,
             int cols)
Creates a new Board instance. This instantiation uses the same set of default letters, but allows the user to specify the number of rows and columns that the bgoard contains.
Parameters:
rows - number of rows the abstract board is to have.
cols - number of columns the abstract board is to have.

Board

public Board(int rows,
             int cols,
             Collection letters)
Creates a new Board instance. This instantiation allows the user to set the number of rows and columns that the board contatins, as well as specify the letters to use. A letter is actually any String, but it is highly recommended that user-defined strings are short, so that they are properly displayed in the GUI.
Parameters:
rows - number of rows the abstract board is to have.
cols - number of columns the abstract board is to have.
letters - the Collection of letters to select from randomly.
Method Detail

rows

public int rows()
Get number of rows in this instantiation of Board.
Returns:
number of rows

columns

public int columns()
Get number of columns in this instantiation of Board.
Returns:
number of columns

letters

public Collection letters()
Get the Collection of letters that the board has stored in its alphabet.
Returns:
the board's alphabet

getLetter

public String getLetter(int x,
                        int y)
Tell which letter is visible at the given board position.
Parameters:
x - x-component of the desired coordinate.
y - y-component of the desired coordinate.
Returns:
Letter at the specified coordinate.

getLetter

public String getLetter(Coordinate coord)
Tell which letter is visible at the given board position.
Parameters:
coord - the desired coordinate.
Returns:
Letter at the specified coordinate.

shake

public void shake()
This method does just what you might think...Scramble the board so that the getLetter methods will return different values than before shaking. Typically, a game of Boggle is initialized by shaking a board and allowing the dice to settle in the grid.