Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. import java.util.*;
  2. public class GameOfLife
  3. {
  4. public static void main(String[] args)
  5.         {
  6.             int[][] boardList = new int[15][15];
  7.             Scanner myScanner = new Scanner(System.in);
  8.             boolean done = false;
  9.             do
  10.             {                
  11.                 System.out.println("1 - Add a being \n 2 - Show current board \n 3 - Show next generation \n 4 - Clear board \n 5 - Add preload pattern \n 6 - Exit");
  12.                 int choice = Integer.parseInt(myScanner.nextLine());
  13.                 if (choice == 1)
  14.                 {
  15.                    System.out.print("Enter the x coordinate: ");
  16.                    String answer = myScanner.nextLine();
  17.                    int xCoordinate = Integer.parseInt(answer);
  18.                    System.out.print("Enter the y coordinate: ");
  19.                    String answer2 = myScanner.nextLine();
  20.                    int yCoordinate = Integer.parseInt(answer2);                  
  21.                    for(int i = 0; i < 15; i++)
  22.                     {
  23.                         for(int j = 0; j < 15; j++)
  24.                         {
  25.                         if(xCoordinate == i)
  26.                             {
  27.                                 if(yCoordinate == j)
  28.                                 {
  29.                                 System.out.printf("x", boardList[i][j]);                                            
  30.                                 }    
  31.                            }
  32.                         else  
  33.                         System.out.printf("-", boardList[i][j]);
  34.                         System.out.println();
  35.                         }
  36.                    }
  37.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement