import java.util.ArrayList; import java.util.Scanner; import java.io.File; public class Dictionary { private ArrayList words; public Dictionary() { this.words = new ArrayList(); } public Dictionary(String fileName) throws java.io.FileNotFoundException { this.words = new ArrayList(); Scanner infile = new Scanner(new File(fileName)); while (infile.hasNext()) { String nextWord = infile.next(); this.addWord(nextWord); } } public boolean addWord(String newWord) { if (!this.findWord(newWord)) { this.words.add(newWord); return true; } return false; } public boolean findWord(String desiredWord) { return this.words.contains(desiredWord); } public int numWords() { return this.words.size(); } public String toString() { return this.words.toString(); } }