import java.util.ArrayList;
import java.util.Random;
/**
 * FooList 
 * 
 * @author Benson Perry
 * @version 1/1/06
 */
public class FooList
{
    private int fooLength;
    private ArrayList availibleFoos;
    private int foosInList;
    public FooList(int length)
    {
        fooLength = length;
        availableFoos = new ArrayList();
    }
    public boolean found(String key)    // tells if the foo is in the list
    {
        for(int i = 0; i < availableFoos.size(); i++)
        {
            if(availableFoos.get(i).equals(key))    // if it's in there somewhere
                return true;        
        }
        return false;
    }//==============================================
    public void addFoo(String entry)    // adds a foo
    {
        if((entry.length()==(fooLength)) && !found(entry))
        {
            availableFoos.add(entry);
            foosInList++;
        }
    }//============================================
    public String removeRandomFoo()
    {
        Random randy = new Random();
        int slot = randy.nextInt(availableFoos.size());
        String word = availableFoos.get(slot);
        availableFoos.remove(slot);
        foosInList--;
        return word;
        
    }//=============================================
    public int getFooLength() { return fooLength;}
    public int getFoosInList() { return foosInList;}
    //============================================
    public String getFoo(int i)
    {
        return availableFoos.get(i);
    }//============================================
    public void fillFooList()
    {
        String word;
        EasyReader console = new EasyReader();
        System.out.println("Type \\q after you're done");
        System.out.println("Enter first word, it must be " + fooLength + " letters long.");
        do{ word = console.readLine();
            addFoo(word);
        }while(!word.equals("\\q"));
    }
    public void printFoos()
     {
        for(int i = 0; i < foosInList; i++)
            System.out.print(availableFoos.get(i) + " ");
        System.out.println();
    }
   
    
}