本附录在单个页面上定义了Karel编程语言的结构。
move();
turnLeft();
putBeeper();
pickBeeper();
/* 评论可以包含在任何部分中
* 的 a 程序. 他们 开始 同 a 削减-星
* and end with a star-slash.
*/public class 名称 extends 超级卡雷尔 {
public void run() {
要执行的代码
}
私有方法的声明
}
frontIsClear() beepersPresent() beepersInBag() leftIsClear() rightIsClear() facingNorth() facingSouth() facingEast() facingWest() frontIsBlocked()
noBeepersPresent() noBeepersInBag() leftIsBlocked() rightIsBlocked() notFacingNorth() notFacingSouth() notFacingEast() notFacingWest() if( 条件 ){
代码run如果条件通过
}
if( 条件 ){
代码块为“是”
} else {
代码块为“否”
}
for(int i = 0; i < 计数 ; i++){
代码重复
}
while( 条件 ){
代码重复
}
private void 名称 () {
代码在方法体中。
}
turnRight();
turnAround();
random( p );
paintCorner( 颜色 );