FooList

//Tony Piechowski

import java.util.ArrayList;
import java.util.Random;
public class FooList
{
    private final int fooLength;
    private ArrayList<String> availableFoos;
 
    public FooList(int length){
       fooLength = length;
       availableFoos = new ArrayList<String>();
       }
    public String getFoo(int x){
        return availableFoos.get(x);
    }
    public boolean found(String key){
       for(int x = 0; x < availableFoos.size(); x++)
       {
           if(key.equals(availableFoos.get(x)))
               return true;
       }
       return false;
    }
    public void addFoo(String foo){
        if(found(foo) || foo.length() != fooLength)
           return;
        availableFoos.add(foo);
    }
   public String removeRandomFoo()
   {
     Random random = new Random();
     int max = availableFoos.size() - 1;
     int rnd = (random.nextInt() * max);
     String foo = availableFoos.get(rnd);
     availableFoos.remove(rnd);
     return foo;
   }
    public int getFooLength( ) {
  for (int i=0;i<availableFoos.length;i++){
                    availableFoos[i] = i;
                    System.out.println("the length of " + i + " is: " + availableFoos[i]);
                }
    }

 public void fillFooList( ) {
  // Code goes here
 }

}
   
   

This site is powered by the Northwoods Titan Content Management System