Przeglądaj źródła

More useless methods and stuff.

master
Ben Kurtovic 12 lat temu
rodzic
commit
028e4bdd83
2 zmienionych plików z 29 dodań i 12 usunięć
  1. +4
    -4
      src/Grid.java
  2. +25
    -8
      src/Patch.java

+ 4
- 4
src/Grid.java Wyświetl plik

@@ -11,8 +11,8 @@ public class Grid {

public Grid(int x, int y) {
_grid = new Patch[x][y];
for(int i = 0; i < x; i++) {
for(int j = 0; j < y; j++) {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
_grid[i][j] = new Patch(this, i, j);
}
}
@@ -36,8 +36,8 @@ public class Grid {

public String toString() {
String ans = "";
for(int i = 0; i < _grid.length; i++) {
for(int j = 0; j < _grid[i].length; j++) {
for (int i = 0; i < _grid.length; i++) {
for (int j = 0; j < _grid[i].length; j++) {
ans += _grid[i][j];
}
ans += "\n";


+ 25
- 8
src/Patch.java Wyświetl plik

@@ -1,19 +1,20 @@
package edu.stuy.goldfish;

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

public Patch(Grid grid, int xcor, int ycor, int state) {
public Patch(Grid grid, int xcor, int ycor, int state, String label) {
_myGrid = grid;
_pxcor = xcor;
_pycor = ycor;
_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() {
@@ -21,11 +22,27 @@ public class Patch {
}

public int getX() {
return _pxcor;
return _xcor;
}

public int getY() {
return _pycor;
return _ycor;
}

public int getState() {
return _state;
}

public void setState(int state) {
_state = state;
}

public String getLabel() {
return _label;
}

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

public String toString() {


Ładowanie…
Anuluj
Zapisz