在整个迷宫中,我试图让我的机器人在每个尚未到达的十字路口放置一个东西(PutThing)。RobotSE有一个布尔方法isBesideThing(),我正在尝试使用它。但是,我一直收到编译错误:
MazeIDudItz.java:24: cannot find symbol
symbol : method isBesideThing()
location: class MazeBot
if(!this.isBesideThing())我已经试过我知道怎么做的一切了。我将其更改为包含返回值的公共布尔方法,但无济于事。这是我的RobotSE类扩展器。这是我的第一堂编程课,所以如果我不清楚或者我说的话不完全有意义,我提前道歉。我知道当我得到这个错误时,我拼写错误了,忘记了一些东西,或者没有导入一些东西。我应该只需要导入becker.robots.*;,因为RobotSE是一个子类。
class MazeBot extends RobotSE
{
public MazeBot(City theCity, int str, int ave, Direction dir, int numThings)
{
super(theCity, str, ave, dir, numThings);
}
private boolean isAtEndSpot()
{
return (this.getAvenue() == 9 && this.getStreet() == 10);
}
public void dontPickThatUp()
{
while(!this.isBesideThing())
{
this.putThing();
}
}
public void moveCheck()
{
if(this.frontIsClear())
{
this.move();
}
else
{
this.turnAround();
}
}
public void checkRight()
{
this.turnRight();
if (this.frontIsClear())
{
this.moveCheck();
}
else
{
this.turnLeft();
this.moveCheck();
}
}
public void NavigateMaze()
{
while (!this.isAtEndSpot())
{
this.checkRight();
}
}
}感谢您的帮助和建议!
发布于 2013-02-19 04:37:10
我要说的是阅读他们的documentation thoroughly.
方法签名是
public boolean isBesideThing(IPredicate kindOfThing)因此,您必须匹配签名并传递IPredicate。
https://stackoverflow.com/questions/14944809
复制相似问题