//----------------------------------------------------------------------------
//Programer:Aaron Eller
//Class Board
//
//
//----------------------------------------------------------------------------
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Board extends Panel
{
    Button [][] board_cell = new Button [10][10];
    
    int [][] cell_status = new int [10][10]; 
    int row, column;
    public int alive=1;//every alive cell will have the value 1
    public int dead=2;//each cell that is dead will have the value 2

//------------------------------------------------------------------------Board  
    public Board(GameInterface new_game)
    {
	
	setLayout (new GridLayout (10,10));

	for( row=0; row < board_cell.length; row++)
	    for( column=0; column < board_cell[0].length; column++)
	    {
	      board_cell [row][column] = new Button();    
		add (board_cell[row][column]);
		board_cell[row][column].addActionListener (new_game);
		board_cell[row][column].setBackground(Color.black);
		cell_status[row][column]=dead;			
	    }
    }  //Board
    
    public void give_life (ActionEvent event)
    {
        for(row=0; row < board_cell.length; row++)
          for(column = 0; column < board_cell[0].length; column++)
          {
              if (event.getSource()== board_cell [row][column])
              {
                if (cell_status[row][column]==dead)
                {
                    board_cell[row][column].setBackground (Color.red);
                    cell_status[row][column]=alive;
                }//end if
                else
                {
                    board_cell[row][column].setBackground (Color.black);
                    cell_status[row][column]=dead;
                }//end else
                
              }//end if
              
          }//end for loop
          
     }//end give_life                 

    public void clear()
    {
      for(row=0; row < board_cell.length; row++)
        for(column=0; column < board_cell[0].length; column++)
        {
            board_cell [row][column].setBackground(Color.black);
            cell_status [row][column]=dead;
        }         

    }//end clear


    public void generation()
    {
        int current_cell = 0;
        int count = 0;
        int [][] temp = new int [10][10];
        int temp_r = 0;//temp file row
        int temp_c = 0; //temp file column
        
                         
        for (row=0; row<10; row++)
        {  for(column=0; column<10; column++)
           { 
             for(temp_r = row-1; temp_r <= row+1; temp_r ++)
             {  for( temp_c = column-1; temp_c <= column+1; temp_c ++)
                 {
                   if (current_cell == alive)
                         count++;
                 }//end temp for
             }//end temp for     
           if(cell_status [row][column] == alive)
                   count--;
           
           temp[row][column]=count;
           } //end for
             
        }//end for  
                   
        for (row=0; row<10; row++)
        {  for(column=0; column<10; column++)
              if (cell_status[row][column] == alive)
              { if temp 
        
        
    }//end generation
}//end class board




