wordFinderPuzzle
Class WFPuzzleReader

java.lang.Object
  extended bywordFinderPuzzle.WFPuzzleReader

public class WFPuzzleReader
extends java.lang.Object

Read a text file which contains a representation of a word finder puzzle. The format of the file is as follows:
Line 1 contains two integers, separated by a space. These are number of rows (r) and number of columns (c) of the puzzle.
The next r lines each contain a string of exactly c characters. These lines represent the rows of characters of the puzzle.
The next line contains a single number, which is the number (w) of words which are to be looked for in the puzzle.
The next w lines each contain one word to be searched for.
Any lines beyond this are ignored.
For example, the following represents a 3x3 puzzle with two words to be searched for:
3 3
cat
ack
rtx
2
cat
act
There is a minimum number of rows and columns that a puzzle must be. The number of rows and columns does not have to be the same.


Field Summary
static int MIN_COLS
          Minimum number of columns a puzzle may have.
static int MIN_ROWS
          Minimum number of rows a puzzle may have.
 
Constructor Summary
WFPuzzleReader(java.lang.String fileID)
          Read in a file from a file.
 
Method Summary
 char[][] getMatrix()
          Get the character matrix of the puzzle that was read in.
 java.lang.String[] getWords()
          Get the list of words which are to be looked for in the puzzle.
 java.lang.String toString()
          Give a short summary of the puzzle that was read in.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_ROWS

public static final int MIN_ROWS
Minimum number of rows a puzzle may have.

See Also:
Constant Field Values

MIN_COLS

public static final int MIN_COLS
Minimum number of columns a puzzle may have.

See Also:
Constant Field Values
Constructor Detail

WFPuzzleReader

public WFPuzzleReader(java.lang.String fileID)
               throws java.io.IOException
Read in a file from a file.

Parameters:
fileID - Identifies a file, which may be local, or may be a URL of a remote file. If local, the file should be on the classpath, in the user directory, or someplace else likely.
The original case of all letters and words is preserved. There is no check for legality of characters or words.
Throws:
java.io.IOException - if there is any error reading the file.
java.lang.IllegalArgumentException - if the file format is illegal.
Method Detail

getMatrix

public char[][] getMatrix()
Get the character matrix of the puzzle that was read in.

Returns:
the character matrix.

getWords

public java.lang.String[] getWords()
Get the list of words which are to be looked for in the puzzle.

Returns:
an array of strings, each of which represents a word to be looked for.

toString

public java.lang.String toString()
Give a short summary of the puzzle that was read in.