From e4b441e7b98983d99adb6592577b5600467e2397 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 15 Jan 2013 18:53:09 -0500 Subject: [PATCH] Setup code should only be executed once. Make run() a loop. --- src/Goldfish.java | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Goldfish.java b/src/Goldfish.java index 05ee0f0..527ff8a 100644 --- a/src/Goldfish.java +++ b/src/Goldfish.java @@ -1,6 +1,5 @@ package edu.stuy.goldfish; - import edu.stuy.goldfish.rules.*; public class Goldfish { @@ -8,34 +7,29 @@ public class Goldfish { private Grid _grid; private Render _render; - public Goldfish () { + public Goldfish() { int height = 96; int width = 96; _render = new Render(width, height); _grid = new Grid(width, height); } - public void run () { - //TODO: make it run. + public void run() { _grid.getPatch(1,0).setState(1); _grid.getPatch(2,1).setState(1); _grid.getPatch(2,2).setState(1); _grid.getPatch(1,2).setState(1); _grid.getPatch(0,2).setState(1); - System.out.println(_grid); - - _grid = LifeWithoutDeath.run(_grid); - System.out.println("------------"); - System.out.println(_grid); - _render.setGrid(_grid); - _render.run(); + while (true) { + _grid = Conway.run(_grid); + _render.setGrid(_grid); + _render.run(); + } } public static void main (String[] args) { Goldfish g = new Goldfish(); - while(true) { - g.run(); - } + g.run(); } }