/**
 * @(#)GameOfLife.java
 *
 * GameOfLife application
 *
 * @author Ramanpreet Singh (romiaujla)
 * @version 1.00 2011/2/11
 */

import java.util.Scanner;

public class GameOfLife 
{
    public static void main(String[] args) 
    {
    	Scanner scan = new Scanner(System.in);
    	
    	final int SIZE = 10;
    	final int GENCOUNT = 9;
    	int i, j, k;
    	int x, y;
    	String opt;
    	char[][] xArr = new char[SIZE][SIZE];
    	
    	
    	for(i = 0; i < xArr.length; i++)
    	{
    		for(j = 0; j < xArr.length; j++)
    		{
    			xArr[i][j] = ' ';
    		}
    	}
    	
    	do
    	{
    		try
    		{
    			System.out.println("Enter the x and y cordinates for adding an Element: ");
    			x = scan.nextInt();
    			y = scan.nextInt();
    			
    			xArr[x-1][y-1] = 'x';
    		}
    		catch(Exception e)
    		{
    			System.out.println("Exception: enter x and y smaller than: " + SIZE);
    		}
    		
    		System.out.println("Would you like to enter another x an y cordinate:");    			
    		opt = scan.next();
    	}while(opt.equalsIgnoreCase("y"));
    	
    	System.out.println("\n\n-----------------------GENERATION # 1-----------------------");
    	System.out.print("   ");
    	for(i = 0; i < xArr.length; i++)
    	{
    		if(i<9)
    			System.out.print(i+1 + "  ");
    		else
    			System.out.print(i+1 + " ");
    	}
    	
    	System.out.println();
    	for(i = 0; i < xArr.length; i++)
    	{
    		if(i<9)
    			System.out.print(i+1 + "  ");
    		else
    			System.out.print(i+1 + " ");
    			
    		for(j = 0; j < xArr.length; j++)
    		{
    			if(j < 9)
    				System.out.print(xArr[i][j] + "  ");    		
    			else
    				System.out.print(xArr[i][j] + " ");
    		}
    		if(i<9)
    			System.out.println("  " + (i+1));
    		else
    			System.out.println(" " + (i+1));
    	}
    	
    	System.out.print("   ");
    	for(i = 0; i < xArr.length; i++)
    	{
    		if(i<9)
    			System.out.print(i+1 + "  ");
    		else
    			System.out.print(i+1 + " ");
    	}
    	
    	
    	
    	//Printing Next 10 Generations
    	for(i = 0; i < GENCOUNT; i++)
    	{
    		System.out.println("\n\n-----------------------GENERATION # " + (i+2) + "-----------------------");
    		System.out.print("   ");
	    	for(j = 0; j < xArr.length; j++)
	    	{
	    		if(j<9)
	    			System.out.print(j+1 + "  ");
	    		else
	    			System.out.print(j+1 + " ");
	    	}
	    	
	    	System.out.println();
	    	for(j = 0; j < xArr.length; j++)
	    	{
	    		if(i<9)
	    			System.out.print(j+1 + "  ");
	    		else
	    			System.out.print(j+1 + " ");
	    			
	    		for(k = 0; k < xArr.length; k++)
	    		{
	    			if(k < 9)
	    				System.out.print(xArr[j][k] + "  ");    		
	    			else
	    				System.out.print(xArr[j][k] + " ");
	    		}
	    		if(j<9)
	    			System.out.println("  " + (j+1));
	    		else
	    			System.out.println(" " + (j+1));
	    	}
	    	
	    	System.out.print("   ");
	    	for(j = 0; j < xArr.length; j++)
	    	{
	    		if(j<9)
	    			System.out.print(j+1 + "  ");
	    		else
	    			System.out.print(j+1 + " ");
	    	}
    	}    	
    }
}

What do you guys think about this..
It does not have an attractive output, but has the functionality needed.
Ramanpreet Singh (romiaujla)

I think it is a program.

I programmed a life game when I was studying data structures and algorithms. It has interesting combinations when you enter as input you will see interesting shapes when the game runs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.