这个错误应该是从网格本身无法移除的。有没有办法让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);
}
}
}
}
答案 0 :(得分:0)
你只需要使用:
super.<method name>();
如果函数是静态的,你可以只Bug.<method name>();