diff --git a/Exam/index.html b/Exam/index.html new file mode 100644 index 0000000..d1f9838 --- /dev/null +++ b/Exam/index.html @@ -0,0 +1,849 @@ + + +
+ ++ Write your Karel program below. Parentheses & semicolons mandatory. + If you’re ever unsure how to use the Simulator, + + consult the manual + . +
+ + + + ++ Karel lives in a 2-D grid (“world”) of square cells. + He can face North/East/South/West, move one cell at a time, + pick up or put down “beepers,” and detect walls. +
+ +.txt
or .kw
world file.;
.()
.if (…){…} [else{…}]
and while (…){…}
.//
.Command | Effect |
---|---|
move() | Step forward if no wall ahead. |
turnLeft() | Rotate 90° counter-clockwise. |
Command | Effect |
---|---|
pickBeeper() | Pick one beeper from current cell. |
putBeeper() | Place one beeper into current cell. |
Condition | True When… |
---|---|
frontIsClear() | No wall immediately in front. |
frontIsBlocked() | Wall immediately in front. |
leftIsClear() | No wall on Karel’s left. |
leftIsBlocked() | Wall on Karel’s left. |
rightIsClear() | No wall on Karel’s right. |
rightIsBlocked() | Wall on Karel’s right. |
nextToABeeper() | One or more beepers in this cell. |
notNextToABeeper() | No beepers in this cell. |
facingNorth() , facingEast() , … |
+ Karel’s orientation matches the named direction. |
anyBeepersInBeeperBag() | Bag contains ≥ 1 beeper. |
noBeepersInBeeperBag() | Bag is empty. |
while ( notNextToABeeper() ) {
+ move();
+}
+pickBeeper();
+turnLeft();
+move();
+putBeeper();
+
+ frontIsClear()
before move()
.if
and while
for complex behaviors.