SpellCheckRunner.java
import java.io.FileNotFoundException;
import java.io.File;
import java.util.Scanner;
/**
This program runs a spell check.
*/
public class SpellCheckRunner
{
public static void main(String[] args) throws FileNotFoundException
{
Scanner in = new Scanner(System.in);
System.out.println("Word list file: ");
String dictionary = in.nextLine();
Scanner dictIn = new Scanner(new File(dictionary));
SpellChecker checker = new SpellChecker(dictIn);
dictIn.close();
System.out.println("File to check: ");
String filename = in.nextLine();
. . .
}
}
SpellChecker.java
import java.util.ArrayList;
import java.util.Scanner;
/**
A class to check the spelling of words.
*/
public class SpellChecker
{
/**
Construct a SpellingCheck object.
@param in the scanner containing a list of properly spelled words
*/
public SpellChecker(Scanner in)
{
. . .
}
/**
Checks if a word is in the word list (ignoring letter case and punctuation)
@param word the word to check for
@return true if word was found, false otherwise
*/
public boolean check(String word)
{
. . .
}
}