Class Board

java.lang.Object
  extended byBoard

public class Board
extends java.lang.Object

This class creates a board for a given ScrabbleBuilder. Class also provides methods for operating on the board. Method placeMove is called by g.endTurn() and is key to validating a player's Move.

Version:
2.0
Author:
3GP01 - Hardev Bhamra, Deepak Chandarana, James Tompkin
See Also:
Game, Move, LetterMove

Constructor Summary
Board(ScrabbleBuilder b)
          Constructs a board given a ScrabbleBuilder b as input.
Board(Square[][] arr)
          Constructs a board given a Square array arr as input.
 
Method Summary
 java.lang.Object clone()
          Clones the current board.
 java.util.ArrayList getRow(int y)
          Returns a row of squares as an ArrayList.
 Square getSquare(int i, int j)
          Gets a square on the board at a given i, j.
 java.util.List getSquares()
          Returns all squares as a List.
 boolean isOccupied(int x, int y)
          Returns a boolean stating whether a specified square is occupied or not (ie whether it has a letter placed on it or not).
 boolean occupiedAdjacent(int x, int y)
          Returns a boolean stating whether a specified occupied square i, j is adjacent to any other occupied squares.
 void placeLetter(Letter l, int x, int y)
          Method to place a given letter on the board on a specific i, j square.
 boolean placeMove(Move m, Board oldboard)
          Returns a boolean stating whether a specified Move.
 void resetMoveSquares(Move m)
          Resets a given Move's used squares.
 java.lang.String toString()
          Returns a String representation of a square.
 boolean validateMove(Move m, int numb)
          Returns a boolean after receiving a boolean from m.validateMove(numb).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Board

public Board(ScrabbleBuilder b)
Constructs a board given a ScrabbleBuilder b as input.

Parameters:
b - The ScrabbleBuilder of the current game.

Board

public Board(Square[][] arr)
Constructs a board given a Square array arr as input.

Parameters:
arr - The Square array to be processed.
Method Detail

clone

public java.lang.Object clone()
Clones the current board.

Returns:
Object A new Board.

getSquare

public Square getSquare(int i,
                        int j)
Gets a square on the board at a given i, j.

Parameters:
i - The i co-ordinate on the board of the required square.
j - The j co-ordinate on the board of the required square.
Returns:
Square The ScrabbleBuilder of the current game.

getRow

public java.util.ArrayList getRow(int y)
Returns a row of squares as an ArrayList.

Parameters:
y - The y co-ordinate of the row you'd like to return.
Returns:
ArrayList The row required.

getSquares

public java.util.List getSquares()
Returns all squares as a List.

Returns:
List A List containing all squares.

isOccupied

public boolean isOccupied(int x,
                          int y)
Returns a boolean stating whether a specified square is occupied or not (ie whether it has a letter placed on it or not).

Parameters:
x - The x co-ordinate of the square you'd like to test.
y - The y co-ordinate of the square you'd like to test.
Returns:
boolean A true or false value.

occupiedAdjacent

public boolean occupiedAdjacent(int x,
                                int y)
Returns a boolean stating whether a specified occupied square i, j is adjacent to any other occupied squares.

Parameters:
x - The x co-ordinate of the square you'd like to test.
y - The y co-ordinate of the square you'd like to test.
Returns:
boolean A true or false value.

validateMove

public boolean validateMove(Move m,
                            int numb)
Returns a boolean after receiving a boolean from m.validateMove(numb).

Parameters:
m - The Move you'd like to validate.
numb - The type of validation you'd like.
Returns:
boolean A true or false value.

placeMove

public boolean placeMove(Move m,
                         Board oldboard)
Returns a boolean stating whether a specified Move.

Parameters:
m - The Move you'd like to place.
oldboard - The Board you'd like it to be placed on.
Returns:
boolean A true or false value.

resetMoveSquares

public void resetMoveSquares(Move m)
Resets a given Move's used squares.

Parameters:
m - The Move you'd like to be reset.

placeLetter

public void placeLetter(Letter l,
                        int x,
                        int y)
Method to place a given letter on the board on a specific i, j square.

Parameters:
l - The Letter you'd like to place.
x - The x co-ordinate of the square you'd like to place a letter.
y - The y co-ordinate of the square you'd like to place a letter.

toString

public java.lang.String toString()
Returns a String representation of a square.

Returns:
String