public class WordTree
extends java.lang.Object
Constructor and Description |
---|
WordTree(java.lang.String fileName)
Construct a WordTree.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isWord(java.lang.String string)
Return true if the argument is a word, false otherwise.
|
int |
longestWord(java.lang.String startString)
Return the length of the longest word that begins with the indicated
string.
|
int |
numWords(java.lang.String startString)
Return the number of words that begin with the indicated string.
|
void |
printWords()
Print all of the words stored in the tree.
|
public WordTree(java.lang.String fileName) throws java.io.FileNotFoundException
fileName
- Location of the word file.java.io.FileNotFoundException
- If the indicated file cannot be opened for readingpublic void printWords()
public int longestWord(java.lang.String startString)
startString
- A string that may start some number of words.public int numWords(java.lang.String startString)
startString
- A string that may start some number of words.public boolean isWord(java.lang.String string)
string
- String which may or may not be a word.