public class CellGrid extends Grid {

	/**
	 * @param p_x_max
	 * @param p_y_max
	 */
	public CellGrid(int p_x_max, int p_y_max) {
		super(p_x_max, p_y_max);
	}

	public void step()
	{
		// System.out.println("Entering step");
		CellState [][] nextStates = new CellState[x_max+1][y_max+1];

		// Because we need to update all cells synchronously, we
		// first calculate the next state for each cell, and store it
		// in a temporary array. Then, we update all the cells.

		for (int x = 0; x <= x_max; x++)
		{
			for (int y = 0; y <= y_max; y++)
			{
				Cell cell = (Cell) getObjectAt(x,y);
				nextStates[x][y] = cell.getNextState();
				
			}
		}
		
		for (int x = 0; x <= x_max; x++)
		{
			for (int y = 0; y <= y_max; y++)
			{
				Cell cell = (Cell) getObjectAt(x,y);
				cell.setState(nextStates[x][y]);
			}
		}
	}
}
