import stanford.karel.*;
public class BanishWinter extends SuperKarel {
public void run() {
while (beepersInBag()) {
moveToTree();
climbTree();
putDownBeeper();
toBottom();
}
}
private void moveToTree() {
while (frontIsClear())
move();
}
private void climbTree() {
while (frontIsBlocked()) {
turnLeft();
move();
turnRight();
}
}
private void putDownBeeper() {
turnLeft();
putTwoBeeper();
turnRight();
move();
turnRight();
putTwoBeeper();
}
private void putTwoBeeper() {
putBeeper();
move();
putBeeper();
}
private void toBottom() {
while (frontIsClear())
move();
turnLeft();
}
}
public class BanishWinter extends SuperKarel {
public void run() {
while (beepersInBag()) {
moveToTree();
climbTree();
putDownBeeper();
toBottom();
}
}
private void moveToTree() {
while (frontIsClear())
move();
}
private void climbTree() {
while (frontIsBlocked()) {
turnLeft();
move();
turnRight();
}
}
private void putDownBeeper() {
turnLeft();
putTwoBeeper();
turnRight();
move();
turnRight();
putTwoBeeper();
}
private void putTwoBeeper() {
putBeeper();
move();
putBeeper();
}
private void toBottom() {
while (frontIsClear())
move();
turnLeft();
}
}