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() {
_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);
}
}
}


+ 4
- 14
src/Patch.java View File

@@ -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);
}
}

+ 2
- 0
src/Render.java View File

@@ -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


Loading…
Cancel
Save