📄 pathfinder.task
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -