2013-02-18 79 views
0

在整個迷宮中,我試圖讓我的機器人把一個東西放下(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(); 
    } 

    } 
} 

我感謝您的幫助和建議!

回答

0

我想說閱讀他們documentation thoroughly.

方法簽名爲

public boolean isBesideThing(IPredicate kindOfThing) 

所以,你必須匹配簽名和傳遞一個IPredicate

+0

我絕對沒有仔細閱讀,謝謝你的幫助! – Leif 2013-04-10 00:31:35