package net.phatcode.rel;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class Dictionary
{

	private List <String> words = new ArrayList<String>();
	
	Dictionary()
	{
		
	}
	
	public void Load( String fileName )
	{
		URL url = this.getClass().getClassLoader().getResource(fileName);
		BufferedReader input;
		
		try 
		{
			input = new BufferedReader(new InputStreamReader(url.openStream()));
			String inputLine;
			
			while( (inputLine = input.readLine()) != null )
			{
				words.add( inputLine );
			}
	     
			input.close();
		} 
		catch( IOException e ) 
		{
			e.printStackTrace();
		}
		
	}
	
	String getRandomWord()
	{
		return words.get( (int)(Math.random()*words.size()) );
	}
	
	int getNumWords()
	{
		return words.size();
	}
	
}
