無法填充網格。每次我這樣做,我得到一個stackoverflow錯誤。這裏是我當前的代碼:Gridworld填充網格
public void removeSelfFromGrid() {
Grid<Actor> grid = getGrid();
int rows = grid.getNumRows();
int cols = grid.getNumCols();
for (int i=0; i<rows; i++) {
for (int j=0; j<cols; j++) {
Location loc = new Location(i, j);
laugh = new CKiller();
laugh.putSelfInGrid(grid, loc);
}
}
}
,這裏是如果需要的話
public CKiller()
{
Color c = null;
setColor(c);
getGrid();
getLocation();
location = new ArrayList<Location>();
location.add(getLocation());
setDirection(direction);
}
構造這裏是錯誤(它的一部分,太大張貼所有它只是那些2條語句重複。) :
java.lang.StackOverflowError
at info.gridworld.actor.Actor.putSelfInGrid(Actor.java:123)
at CKiller.removeSelfFromGrid(CKiller.java:120)
它說這是問題
laugh.putSelfInGrid(grid, loc);