Advertisement
xFazz

Cell Life

Sep 26th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public class Testing {
  2.  
  3. public static void main(String[] args) {
  4. Cell[][] world = new Cell[20][20];
  5.  
  6. loadInitialPopulation();
  7. printGeneration();
  8.  
  9. }
  10.  
  11. private static void loadInitialPopulation(Cell[][] world) {
  12. File file = new File(pathname: "Life100.txt");
  13.  
  14. // set up array
  15. for (int r = 0; r < world.length; r++)
  16. for (int c = 0; c < world[r].length; c++)
  17. world[r][c] = new Cell();
  18.  
  19. // load file
  20. try {
  21. Scanner scan = new Scanner(file);
  22. while (scan.hasNextLine()) {
  23. int row = scan.nextInt();
  24. int col = scan.nextInt();
  25. world[row - 1][col - 1].birth();
  26. }
  27. scan.close();
  28.  
  29. } catch (FileNotFoundException e) {
  30. e.printStackTrace();
  31. }
  32.  
  33. }
  34. // go through the array and where there's an alive cell you print a star
  35. private static void printGeneration() {
  36.  
  37.  
  38. }
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement