pathfinder.task
来自「用JAVA编写的小机器人运动盖房子的小程序.」· TASK 代码 · 共 65 行
TASK
65 行
class Pathfinder extends Robot {
//streetExit and avenueExit are the coordinates of the exit
void turnRight(){ turnLeft(); turnLeft(); turnLeft(); } void escape(int streetExit, int avenueExit) {
// diese Methode ist nur fur lab2 /* turnRight(); while(frontIsClear()) move(); turnLeft(); while(frontIsClear()){ while(frontIsClear())move(); turnRight(); } turnLeft(); turnLeft(); while(frontIsClear()){ while(frontIsClear()&&!nextToABeeper())move(); turnLeft(); } pickBeeper(); turnOff(); } } */ // diese Method ist allgemein ! while(!areYouHere(streetExit,avenueExit)) { if(frontIsClear()) move(); else{ turnRight(); if(frontIsClear()) move(); else{turnLeft(); turnLeft(); if(frontIsClear()) move();} }} pickBeeper(); turnOff(); } } //Please write here your code
task {
//exit on 1,10
// World.readWorld("lab2.wld");
//exit on 5,13
World.readWorld("lab1.wld");
Pathfinder k = new Pathfinder(1,1,0,North);
k.escape(5,13);
//k.escape(1,10);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?