For this assignment, you will implement a simple, interactive spell checker that processes a text file, reading every word from the file and identifying which are misspelled (i.e., not found in a dictionary file). For each misspelled word, the user will be prompted with three options: they can add the word to the dictionary, they can ignore every subsequent occurrence of the word in that file, or they can ignore that occurrence and continue processing.
You are given the Dictionary class and the javadoc page for your SpellChecker class.
Modify the Dictionary class so that, instead of throwing exceptions whenever a file or I/O error occurs, it catches those exceptions and displays an appropriate error message. Recall that in Java, exception-handling is implemented using the try-catch mechanism:
Implement the SpellChecker
class so that it meets the javadoc specifications. Note that the class has only one public method, checkFile
, which checks the specified file for misspelled words. However, since this is a relatively complex task, you will probably want to have one or more private helper methods to split up the work. Also note the following requirements:
checkFile
method begins processing a file, it should display a message of the form PROCESSING filename
, and should likewise display a message of the form DONE PROCESSING filename
when done.
checkFile
method should write the updated dictionary contents back to the same file when done (and display a message of the form UPDATING dictFilename
). Note that this should only happen if the dictionary was updated when processing the file.