这个错误应该是无法从网格中移除的。有没有办法让 ConnorBug 从原始 Bug 类中执行 removeSelfFromGrid() 并真正摆脱网格中的错误?
public class ConnorBug extends Bug
{
public static int MyNewCounter = 0;
public ConnorBug()
{
setColor(null);
}
public void removeSelfFromGrid()
{
Location loc = getLocation();
Grid<Actor> gr = getGrid();
Location next = loc.getAdjacentLocation(getDirection());
if(gr.isValid(next))
{
this.move();
}
else{
this.setDirection(getDirection()-180);
this.move();
}
for(int c=0; c<8; c++)
{
Location thatLoc = getLocation();
Location thatNext = thatLoc.getAdjacentLocation((0+(45*c)));
if(gr.isValid(thatNext)&&!(gr.get(thatNext) instanceof ConnorRock)&&!(gr.get(thatNext) instanceof ConnorBug))
{
ConnorRock something = new ConnorRock();
something.putSelfInGrid(gr,thatNext);
}
}
}
}