CSC 222: Object-Oriented Programming
Spring 2012

HW 4: Lists and Files

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.

Part 1: Exception handling

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:

try { // CODE TO BE ATTEMPTED } catch (EXCEPTION_TYPE e) { // CODE TO EXECUTE IF EXCEPTION OCCURS }

Part 2: SpellChecker

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: