public class Dictionary
extends java.lang.Object
Constructor and Description |
---|
Dictionary()
Create an empty dictionary
|
Dictionary(java.lang.String filename)
Create a dictionary from a file.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String word)
Add a word into the dictionary
|
boolean |
check(java.lang.String word)
Checks to see if a word is in the dictionary.
|
boolean |
checkPrefix(java.lang.String prefix)
Checks to see if a prefix matches a word in the dictionary.
|
void |
print()
Print out the contents of the dictionary, in alphabetical order, one word per line.
|
void |
remove(java.lang.String word)
Remove a word from the dictionary
|
java.lang.String |
suggest(java.lang.String word)
Return a the entry in the dictionary that is as close as possible to
the parameter word.
|
public Dictionary()
public Dictionary(java.lang.String filename)
filename
- Name of the file containing the words to add to the dictionarypublic void add(java.lang.String word)
word
- The word to add to the dictionarypublic void print()
public void remove(java.lang.String word)
word
- The word to removepublic java.lang.String suggest(java.lang.String word)
word
- The word word to checkpublic boolean check(java.lang.String word)
word
- The word to checkpublic boolean checkPrefix(java.lang.String prefix)
prefix
- The prefix to check