Written by Eric Roberts
This appendix defines the structure of the Karel programming language on a single page.
move();
turnLeft();
putBeeper();
pickBeeper();
/*
* Comments can be included in any part
* of a program. They start with a slash-star
* and end with a star-slash.
*/
public class name extends SuperKarel {
public void run() {
declarations to repeat
}
definitions of private methods
}
frontIsClear()beepersPresent()beepersInBag()leftIsClear()rightIsClear()facingNorth()facingSouth()facingEast()facintWest()frontIsBlocked()
noBeepersPresent()noBeepersInBag()leftIsBlocked()rightIsBlocked()notFacingNorth()notFacingSouth()notFacingEast()notFacingWest()if(condition){
code run if condition passes}
if(condition){
code block for "yes"} else {
code block for "no"}
for(int i = 0; i < count; i++){
declarations to repeat}
while(condition){
declarations to repeat}
private voidname() {
commands in the body of the method.}
turnRight();
turnAround();
random(p);
paintCorner(color);