import edu.kzoo.grid.display.DisplayMap; import edu.kzoo.grid.display.ScaledImageDisplay; import edu.kzoo.grid.gui.GridAppFrame; import edu.kzoo.grid.gui.GridPkgFactory; import edu.kzoo.grid.gui.nuggets.BasicHelpMenu; import edu.kzoo.util.Debug; public class MysteryApp { public static void main(String[] args) { Class[] controllers = { SlowController.class }; // Create and show the window containing the graphical user interface. GridAppFrame window = new MysteryGUI(controllers); window.includeMenu(new BasicHelpMenu("MysteryApp", "Your Name Here", "with assistance from (whom?)", "version date", "file:MysteryApp.html")); window.constructWindowContents("MysteryApp Program", null, 0, 0, 0); } } ======= THIS SHOULD BE IN A SEPARATE FILE ======= import java.util.ArrayList; import edu.kzoo.grid.Grid; import edu.kzoo.grid.GridObject; import edu.kzoo.grid.Location; public class SlowController extends MysteryController { private boolean stepDidSomething; public SlowController() { super(); stepDidSomething = false; } /** Advances the application one step. */ public void step() { // Note that a new step is beginning, controlled by this controller. setController(this); // inherited method stepDidSomething = false; // no activity in this step yet! Grid g = getGrid(); for ( int row = 0; row < g.numRows(); row++ ) for ( int col = 0; col < g.numCols(); col++ ) { GridObject obj = g.objectAt(new Location(row, col)); if ( obj != null ) obj.act(); } } /** Takes note of the fact that something happened. */ public void note(GridObject newObj) { stepDidSomething = true; } /** Determines whether a running application has reached * a desired stopping state. * @return true if the application should stop **/ public boolean hasReachedStoppingState() { return ! stepDidSomething; } } ======= THIS SHOULD BE IN A SEPARATE FILE ======= import edu.kzoo.grid.GridObject; import edu.kzoo.grid.Location; import edu.kzoo.util.Debug; public class MysteryGridObject extends GridObject { public void act() { Location something = getSomething(); doIt(something); } protected Location getSomething() { int currentRow = location().row(); int currentCol = location().col(); return new Location(currentRow+1, currentCol); } protected void doIt(Location newLoc) { if ( ! grid().isEmpty(newLoc) ) return; GridObject dupl = new MysteryGridObject(); grid().add(dupl, newLoc); appController.getController().note(dupl); } }