Browse Source

Adding some methods because Josh.

master
Ben Kurtovic 11 years ago
parent
commit
22d1af5b20
2 changed files with 27 additions and 6 deletions
  1. +10
    -2
      src/Grid.java
  2. +17
    -4
      src/Patch.java

+ 10
- 2
src/Grid.java View File

@@ -18,11 +18,19 @@ public class Grid {
}
}

public Patch getPatch (int x, int y) {
public int getWidth() {
return _grid.length;
}

public int getHeight() {
return _grid[0].length;
}

public Patch getPatch(int x, int y) {
return _grid[x][y];
}

public void setPatch (int x, int y, Patch p) {
public void setPatch(int x, int y, Patch p) {
_grid[x][y] = p;
}



+ 17
- 4
src/Patch.java View File

@@ -1,18 +1,31 @@
package edu.stuy.goldfish;

public class Patch {
private int _pxcor, _pycor;
private int _pxcor, _pycor, _state;
private String _plabel;
private Grid _myGrid;

public Patch(Grid grid, int xcor, int ycor) {
public Patch(Grid grid, int xcor, int ycor, int state) {
_myGrid = grid;
_pxcor = xcor;
_pycor = ycor;
_state = state;
}

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

public Grid getGrid() {
return _grid;
}

public int getX() {
return _pxcor;
}

public int getY() {
return _pycor;
}

public String toString() {


Loading…
Cancel
Save