import java.util.*;
import javax.swing.JFrame;
public class Life
{
	public static void main (String[] args)
	{
		int choice=0;
		 Board myBoard=new Board();
		myBoard.createBlankWorld (myBoard.world, myBoard.width, myBoard.height);
		// Graphics stuff -----------------------------------------------
		
		JFrame application = new JFrame();
		application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		application.add(myBoard);
		application.setSize(250,250);
		application.setVisible(true);
		//end of graphics stuff ------------------------------------------
		Scanner input = new Scanner (System.in);
		int ANIMATION_DELAY=50;
		Timer animationTimer;
		int i;
        
		         //start life with an empty world
        	 myBoard.createBlankWorld (myBoard.world, myBoard.width, myBoard.height);
		         
		         //decide on starting population
		         choice=menu( myBoard);
        do
        {
		        
		         for(i=1;i<1;i++)
		         {
		        	//	
		        	 myBoard.showWorld(myBoard.world ,myBoard.width, myBoard.height);
		        	 myBoard.countNeighbours(myBoard.world ,myBoard.width, myBoard.height);
				
		        	
		        	//start timer					
		        }
		         
		         System.out.println("Would you like to repeat the program? (0-no/1-yes) ");
			     choice = input.nextInt();
		         
        }while (choice!=0);
        System.out.println("finished with world");
	}
	public static int menu( Board theBoard)
	{
		int menuChoice; 
		Scanner inputValue = new Scanner (System.in);
		System.out.println("Welcome to life ");
        System.out.println("1. Simple world ***** ***** ***** ");
        System.out.println("2. Random World ");
        System.out.println("3. Pick Density ");
        System.out.println("0. Quit ");
        System.out.println("Please enter your choice ");
        menuChoice = inputValue.nextInt();
        if (menuChoice==1)
       	 theBoard.populateWorld (theBoard.world, theBoard.width, theBoard.height);
        else if (menuChoice==2)
       	 theBoard.randomWorld (theBoard.world, theBoard.width, theBoard.height);
        else if (menuChoice==3)
       	 theBoard.densityWorld (theBoard.world, theBoard.width, theBoard.height);
        return (menuChoice);
	}
} 