Class WordNode

java.lang.Object
  extended by WordNode

public class WordNode
extends java.lang.Object

Objects of the WordNode class represent a node in a WordTree. User's should not interact with WordNodes directly.

Version:
V1.0, 03/2012
Author:
Nathan Sprague

Constructor Summary
WordNode(char letter)
          WordNode constructor.
 
Method Summary
 void addLetters(java.lang.String letters)
          Letters represents the end of some word.
 int calcLongestWord(int depth)
          Pre-compute and store the longest word under this node in the tree.
 boolean isWord(java.lang.String string)
          Recursively check to see if the indicated string contains a word.
 int longestWord(java.lang.String string)
          Return the length of the longest word under this node with the indicated beginning.
 int numWords(java.lang.String string)
          Return the length of the number of words under this node with the indicated beginning.
 void printWords(java.lang.String wordSoFar)
          Recursively print every word stored under this node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordNode

public WordNode(char letter)
WordNode constructor.

Parameters:
letter - The letter stored in this node.
Method Detail

calcLongestWord

public int calcLongestWord(int depth)
Pre-compute and store the longest word under this node in the tree. This should only be called once after the entire tree has been built.

Parameters:
depth - The depth of this node in the tree.
Returns:
The length of the longest word under this node in the tree.

addLetters

public void addLetters(java.lang.String letters)
Letters represents the end of some word. Recursively add the word to the tree.

Parameters:
letters - The end of a word.

printWords

public void printWords(java.lang.String wordSoFar)
Recursively print every word stored under this node.

Parameters:
wordSoFar - All the letters on the path from the root to this node.

longestWord

public int longestWord(java.lang.String string)
Return the length of the longest word under this node with the indicated beginning.

Parameters:
string - The beginning of some word.
Returns:
The length of the longest word with that beginning.

numWords

public int numWords(java.lang.String string)
Return the length of the number of words under this node with the indicated beginning.

Parameters:
string - The beginning of some word or words.
Returns:
The number of words with the indicated beginning.

isWord

public boolean isWord(java.lang.String string)
Recursively check to see if the indicated string contains a word.

Parameters:
string - The end of the current word being checked.
Returns:
True if it is a word, false otherwise.