Parcourir la source

Adding some methods because Josh.

master
Ben Kurtovic il y a 12 ans
Parent
révision
22d1af5b20
2 fichiers modifiés avec 27 ajouts et 6 suppressions
  1. +10
    -2
      src/Grid.java
  2. +17
    -4
      src/Patch.java

+ 10
- 2
src/Grid.java Voir le fichier

@@ -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 Voir le fichier

@@ -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() {


Chargement…
Annuler
Enregistrer