/** * @(#)TextLife.java * * TextLife application - This program is intended to create a text interface of *the game of Life by John Conway based on the 1970 American Scientific article. * * @author John Stewart * @version 1.00 2010/11/3 */ import java.util.Scanner; import java.io.*; public class TextLife { //-------------------------------------------------------------------------------------------------- public static void drawBoard(int maxRows,int maxCols,boolean[][]cell){ for (int i = 0;i3)){return false;} else {return true;} } else { if (liveNeighbours==3) {return true;} else {return false; } } //return false; } //-------------------------------------------------------------------------------------------------- public static void main(String[] args) { int x = 0; //the column that the cell is located in int y = 0; //the row that the cell is located in int maxCells = 0; //the largest number of cells alive in any generation int generation = 0; //the number of the current generation of the colony int maxRows = 0; //defines the maximum number of rows in the colony int maxCols = 0;//defines the maximum number of columns in the colony String dataLine = ""; Scanner keyboard = new Scanner(System.in); String inputFileName = ""; System.out.print("Name of file: "); inputFileName = keyboard.nextLine(); try { //create the array for the colony FileInputStream fstream = new FileInputStream(inputFileName); DataInputStream in = new DataInputStream(fstream); maxCols = Integer.parseInt(in.readLine()); maxRows = Integer.parseInt(in.readLine()); System.out.println (maxCols + " "+maxRows); boolean [][] cell; cell = new boolean[maxCols][maxRows]; //declare the size of the colony boolean [][] nextGenCell; //create the array for the colony nextGenCell = new boolean[maxCols][maxRows]; //declare the size of the colony for (int i = 0;i