// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   Dictionary.java

import java.io.*;

public class Dictionary
{

    public Dictionary()
    {
        dictionary = new List();
        temp = "";
        total = 0;
        createDictionary();
    }

    public void createDictionary()
    {
        boolean flag = false;
        try
        {
            FileReader filereader = new FileReader("Dictionary.dat");
            BufferedReader bufferedreader = new BufferedReader(filereader);
            while(!flag) 
            {
                temp = bufferedreader.readLine();
                if(temp == null)
                {
                    flag = true;
                } else
                {
                    dictionary.addEnd(temp);
                    total++;
                }
            }
            bufferedreader.close();
        }
        catch(IOException ioexception)
        {
            System.out.println("ERROR - File \"Dictionary.dat\" not found.");
            return;
        }
    }

    public void saveFile()
    {
        try
        {
            FileWriter filewriter = new FileWriter("Dictionary.dat");
            BufferedWriter bufferedwriter = new BufferedWriter(filewriter);
            PrintWriter printwriter = new PrintWriter(bufferedwriter);
            printwriter.println(dictionary.toFormattedString());
            printwriter.close();
        }
        catch(IOException ioexception)
        {
            System.out.println("ERROR - File \"Dictionary.dat\" not found.");
            System.out.println("ERROR - " + ioexception.toString());
            return;
        }
        catch(SecurityException securityexception)
        {
            System.out.println("Save restriction, obviously. - " + securityexception.toString());
        }
    }

    public boolean isWord(String s)
    {
        return dictionary.objectExists(s);
    }

    public void addWord(String s)
    {
        total++;
        dictionary.addEnd(s);
    }

    public void addWordInPlace(String s)
    {
        total++;
        dictionary.addInPlace(s);
    }

    public String getWord(int i)
    {
        return (String)dictionary.getObjectAt(i);
    }

    public int getTotalWords()
    {
        return total;
    }

    private List dictionary;
    private String temp;
    private int total;
}

