Browse Source

Removing old label thing for patches

master
Ben Kurtovic 11 years ago
parent
commit
63ca5e50f1
3 changed files with 8 additions and 16 deletions
  1. +2
    -2
      src/Grid.java
  2. +4
    -14
      src/Patch.java
  3. +2
    -0
      src/Render.java

+ 2
- 2
src/Grid.java View File

@@ -6,14 +6,14 @@ public class Grid {


public Grid() { public Grid() {
_grid = new Patch[1][1]; _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) { public Grid(int x, int y) {
_grid = new Patch[y][x]; _grid = new Patch[y][x];
for (int i = 0; i < x; i++) { for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) { 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);
} }
} }
} }


+ 4
- 14
src/Patch.java View File

@@ -2,19 +2,17 @@ package edu.stuy.goldfish;


public class Patch { public class Patch {
private int _xcor, _ycor, _state; private int _xcor, _ycor, _state;
private String _label;
private Grid _grid; 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; _grid = grid;
_xcor = xcor; _xcor = xcor;
_ycor = ycor; _ycor = ycor;
_state = state; _state = state;
_label = label;
} }


public Patch() { public Patch() {
this(new Grid(), 0, 0, 0, "");
this(new Grid(), 0, 0, 0);
} }


public Grid getGrid() { public Grid getGrid() {
@@ -37,16 +35,8 @@ public class Patch {
_state = state; _state = state;
} }


public String getLabel() {
return _label;
}

public void setLabel(String label) {
_label = label;
}

public String toString() { public String toString() {
return _label + " " + ((_state == 0) ? "." : _state);
return "" + ((_state == 0) ? "." : _state);
} }


public Patch[] get4Neighbors() { public Patch[] get4Neighbors() {
@@ -72,6 +62,6 @@ public class Patch {
} }


public Patch clone(Grid grid) { public Patch clone(Grid grid) {
return new Patch(grid, _xcor, _ycor, _state, _label);
return new Patch(grid, _xcor, _ycor, _state);
} }
} }

+ 2
- 0
src/Render.java View File

@@ -150,6 +150,8 @@ public class Render extends Canvas implements Runnable, MouseListener,
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
_grid.getPatch(e.getX() / scale, e.getY() / scale).setState(1);
e.consume();
} }
@Override @Override


Loading…
Cancel
Save