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