diff --git a/src/Grid.java b/src/Grid.java index 5b210bd..b979a31 100644 --- a/src/Grid.java +++ b/src/Grid.java @@ -6,14 +6,14 @@ public class Grid { public Grid() { _grid = new Patch[1][1]; - _grid[0][0] = new Patch(this, 0, 0, 0, ""); + _grid[0][0] = new Patch(this, 0, 0, 0); } public Grid(int x, int y) { _grid = new Patch[y][x]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { - _grid[j][i] = new Patch(this, i, j, 0, ""); + _grid[j][i] = new Patch(this, i, j, 0); } } } diff --git a/src/Patch.java b/src/Patch.java index 2e93cce..13d0a33 100644 --- a/src/Patch.java +++ b/src/Patch.java @@ -2,19 +2,17 @@ package edu.stuy.goldfish; public class Patch { private int _xcor, _ycor, _state; - private String _label; private Grid _grid; - public Patch(Grid grid, int xcor, int ycor, int state, String label) { + public Patch(Grid grid, int xcor, int ycor, int state) { _grid = grid; _xcor = xcor; _ycor = ycor; _state = state; - _label = label; } public Patch() { - this(new Grid(), 0, 0, 0, ""); + this(new Grid(), 0, 0, 0); } public Grid getGrid() { @@ -37,16 +35,8 @@ public class Patch { _state = state; } - public String getLabel() { - return _label; - } - - public void setLabel(String label) { - _label = label; - } - public String toString() { - return _label + " " + ((_state == 0) ? "." : _state); + return "" + ((_state == 0) ? "." : _state); } public Patch[] get4Neighbors() { @@ -72,6 +62,6 @@ public class Patch { } public Patch clone(Grid grid) { - return new Patch(grid, _xcor, _ycor, _state, _label); + return new Patch(grid, _xcor, _ycor, _state); } } diff --git a/src/Render.java b/src/Render.java index 77edf16..671b534 100644 --- a/src/Render.java +++ b/src/Render.java @@ -150,6 +150,8 @@ public class Render extends Canvas implements Runnable, MouseListener, @Override public void mousePressed(MouseEvent e) { + _grid.getPatch(e.getX() / scale, e.getY() / scale).setState(1); + e.consume(); } @Override