Class Board

java.lang.Object
  extended by Board

public class Board
extends java.lang.Object


Constructor Summary
Board()
           
Board(java.lang.String boardfile)
           
 
Method Summary
 int addTile(Tile letter, int row, int col)
          Adds a letter to the board, returns -1 if unsuccessful Otherwise, it adds the letter and returns the amount of points gained.
 int calculatePoints(java.util.ArrayList<Square> pieces)
          Takes in a ArrayList of the location of the new pieces
 int calculatePoints(int row, int col)
          Calculates the amount of points gained by the recent placement of the piece at [row, col].
 boolean checkWord(Word word)
          Checks whether the word passed in exists in the dictionary
 Square[][] getBoard()
           
 Word getHorizontalWord(int row, int col)
          Returns a Word, the horizontal word begining at [row,col]
 java.util.ArrayList<Square> getHorizontalWordSquares(int row, int col)
          Returns the list of squares making up the word beginning at row, col [word]
 int[] getHorizontalWordStart(int row, int col)
          Returns [x,y] point of the start of a word, [-1,-1] if invalid
 Word getVerticalWord(int row, int col)
          Returns a ArrayList, the vertical word begining at [row,col]
 java.util.ArrayList<Square> getVerticalWordSquares(int row, int col)
          Returns the list of squares making up the word beginning at row, col [vertical]
 int[] getVerticalWordStart(int row, int col)
          Returns [x,y] point of the start of a word, [-1,-1] if invalid
 void init()
           
protected  void makeBoard()
          Reads the board from a file and inits the board attribute.
 void setBoard(Square[][] board)
           
 java.lang.String toString()
           
static java.util.ArrayList<java.lang.String> WordsExist(java.util.ArrayList<java.lang.String> words)
          Checks to see if any of the words in the list are actual words.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Board

public Board()

Board

public Board(java.lang.String boardfile)
Method Detail

init

public void init()

makeBoard

protected void makeBoard()
                  throws java.io.FileNotFoundException
Reads the board from a file and inits the board attribute.

Throws:
java.io.FileNotFoundException

addTile

public int addTile(Tile letter,
                   int row,
                   int col)
Adds a letter to the board, returns -1 if unsuccessful Otherwise, it adds the letter and returns the amount of points gained. It is unsuccessful if it the point is already occupied, if any non-word is created


WordsExist

public static java.util.ArrayList<java.lang.String> WordsExist(java.util.ArrayList<java.lang.String> words)
Checks to see if any of the words in the list are actual words. Returns an array of only the existing words


calculatePoints

public int calculatePoints(java.util.ArrayList<Square> pieces)
Takes in a ArrayList of the location of the new pieces

Parameters:
pieces -
Returns:

calculatePoints

public int calculatePoints(int row,
                           int col)
Calculates the amount of points gained by the recent placement of the piece at [row, col].


getHorizontalWordStart

public int[] getHorizontalWordStart(int row,
                                    int col)
Returns [x,y] point of the start of a word, [-1,-1] if invalid

Parameters:
row -
col -
Returns:

getVerticalWordStart

public int[] getVerticalWordStart(int row,
                                  int col)
Returns [x,y] point of the start of a word, [-1,-1] if invalid

Parameters:
row -
col -
Returns:

getHorizontalWord

public Word getHorizontalWord(int row,
                              int col)
Returns a Word, the horizontal word begining at [row,col]

Parameters:
row -
col -
Returns:
the word object

getHorizontalWordSquares

public java.util.ArrayList<Square> getHorizontalWordSquares(int row,
                                                            int col)
Returns the list of squares making up the word beginning at row, col [word]

Parameters:
row - the starting row
col - the ending column
Returns:
list of squares making up the word

getVerticalWordSquares

public java.util.ArrayList<Square> getVerticalWordSquares(int row,
                                                          int col)
Returns the list of squares making up the word beginning at row, col [vertical]

Parameters:
row - the starting row
col - the ending column
Returns:
list of squares making up the word

getVerticalWord

public Word getVerticalWord(int row,
                            int col)
Returns a ArrayList, the vertical word begining at [row,col]

Parameters:
row -
col -
Returns:
returns a word

setBoard

public void setBoard(Square[][] board)

getBoard

public Square[][] getBoard()

checkWord

public boolean checkWord(Word word)
Checks whether the word passed in exists in the dictionary

Parameters:
word - the word to check
Returns:
true or false

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object