首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Karel Robot:找不到符号

Karel Robot:找不到符号
EN

Stack Overflow用户
提问于 2013-02-19 04:33:01
回答 1查看 1.2K关注 0票数 0

在整个迷宫中,我试图让我的机器人在每个尚未到达的十字路口放置一个东西(PutThing)。RobotSE有一个布尔方法isBesideThing(),我正在尝试使用它。但是,我一直收到编译错误:

代码语言:javascript
复制
MazeIDudItz.java:24: cannot find symbol
symbol  : method isBesideThing()
location: class MazeBot
        if(!this.isBesideThing())

我已经试过我知道怎么做的一切了。我将其更改为包含返回值的公共布尔方法,但无济于事。这是我的RobotSE类扩展器。这是我的第一堂编程课,所以如果我不清楚或者我说的话不完全有意义,我提前道歉。我知道当我得到这个错误时,我拼写错误了,忘记了一些东西,或者没有导入一些东西。我应该只需要导入becker.robots.*;,因为RobotSE是一个子类。

代码语言:javascript
复制
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();
    }

  }   
}

感谢您的帮助和建议!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-19 04:37:10

我要说的是阅读他们的documentation thoroughly.

方法签名是

代码语言:javascript
复制
public boolean isBesideThing(IPredicate kindOfThing)

因此,您必须匹配签名并传递IPredicate

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14944809

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档