Code
import stanford.karel.Karel;
/**
*/
/**
* @author student
*/
/**
* @param args
*/
while (frontIsClear()) {
fillPothole();
move();
turnRight();
move();
putBeeper();
turnAround();
move();
turnRight();
move();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
}
2)
Code
import stanford.karel.Karel;
/**
*/
/**
* @author student
*/
/**
* @param args
*/
while (frontIsClear()) {
move();
while (leftIsClear()) {
turnLeft();
move();
putBeeper();
turnAround();
move();
turnLeft();
move();
turnAround();
while (frontIsClear()) {
move();
while (leftIsClear()) {
turnLeft();
move();
putBeeper();
turnAround();
move();
turnLeft();
move();
}
}
turnAround();
turnLeft();
turnLeft();
}
3)
Code
import stanford.karel.Karel;
/**
*/
/**
* @author student
*/
/**
* @param args
*/
while (frontIsClear()) {
move();
turnRight();
move();
putBeeper();
turnAround();
move();
move();
turnRight();
move();
move();
move();
turnRight();
move();
putBeeper();
turnAround();
move();
turnRight();
move();
move();
move();
turnRight();
move();
putBeeper();
turnAround();
move();
turnRight();
move();
turnLeft();
while (frontIsClear()) {
move();
turnLeft();
while (frontIsClear()) {
move();
turnLeft();
while (frontIsClear()) {
move();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
4)
Code
import stanford.karel.Karel;
/**
*/
/**
* @author student
*/
* @param args
*/
turnLeft();
move();
turnRight();
move();
turnLeft();
move();
turnRight();
move();
pickBeeper();
move();
pickBeeper();
move();
turnRight();
move();
turnLeft();
move();
turnRight();
move();
putBeeper();
turnAround();
move();
turnRight();
move();
turnLeft();
move();
turnRight();
move();
move();
turnRight();
move();
putBeeper();
turnAround();
move();
turnRight();
move();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
}
5)
Code
import stanford.karel.Karel;
/**
*/
/**
* @author student
*/
* @param args
*/
while (frontIsClear()) {
move();
turnLeft();
move();
turnRight();
while (frontIsClear()) {
move();
pickBeeper();
turnLeft();
move();
turnRight();
while (frontIsClear()) {
move();
pickBeeper();
turnLeft();
move();
turnRight();
while (frontIsClear()) {
move();
}
}
turnLeft();
turnLeft();
turnLeft();