Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Omar Natour 11/30/16
- * Csc-220 Data Structures
- * Hw8 Spell checker
- * create a program that can check words against a created dictionary class
- * ojnatour0001@student.stcc.edu
- */
- package chapter24;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Dictionary<E extends String> extends MostRecentlyUsedLinkedList<E> {
- public Dictionary() {
- }
- public Dictionary(E[] words) {
- super();
- }
- @SuppressWarnings("unchecked")
- public void loadDictionary(String filename) {
- try {
- Scanner sc = new Scanner(new File("chapter24/" + filename));
- while (sc.hasNextLine())
- this.add((E) sc.nextLine());
- sc.close();
- } catch (FileNotFoundException fnfe) {
- System.err.println(fnfe);
- } catch (Exception e) {
- System.err.println(e);
- }
- }
- public int lookUpWord(E word) {
- return this.indexOf(word);
- }
- }
Add Comment
Please, Sign In to add comment