@@ -0,0 +1,1315 @@
+/*%0A * File: MidpointFindingKarel.java%0A * -------------------------------%0A * When you finish writing it, the MidpointFindingKarel class should%0A * leave a beeper on the corner closest to the center of 1st Street%0A * (or either of the two central corners if 1st Street has an even%0A * number of corners).  Karel can put down additional beepers as it%0A * looks for the midpoint, but must pick them up again before it%0A * stops.  The world may be of any size, but you are allowed to%0A * assume that it is at least as tall as it is wide.%0A */%0A%0Aimport stanford.karel.*;%0A%0A/* Note: this fails if the world is only one street wide. I'm not sure if that's %0A * permissible or not.%0A */%0Apublic class MidpointFindingKarel2 extends SuperKarel %7B%0A%09public void run() %7B%0A%09%09setup();%0A%09%09while (frontIsBlocked()) %7B%0A%09%09%09turnAround();%0A%09%09%09moveToFirstBeeper();%0A%09%09%09grabAndGo();%0A%09%09%7D%0A%09%7D%0A%09%0A%09private void setup() %7B%0A%09%09while (frontIsClear()) %7B%0A%09%09%09putBeeper();%0A%09%09%09move();%0A%09%09%7D%0A%09%09putBeeper();%0A%09%7D%0A%09%0A%09private void moveToWall() %7B%0A%09%09while (frontIsClear()) %7B%0A%09%09%09move();%0A%09%09%7D%0A%09%7D%0A%09%0A%09private void grabAndGo() %7B%0A%09%09if (beepersPresent()) %7B%0A%09%09%09pickBeeper();%0A%09%09%09move();%0A%09%09%09if (beepersPresent()) %7B%0A%09%09%09%09moveToWall();%0A%09%09%09%7D else %7B%0A%09%09%09%09turnAround();%0A%09%09%09%09move();%0A%09%09%09%09putBeeper();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%09%0A%09private void moveToFirstBeeper() %7B%0A%09%09while (noBeepersPresent()) %7B%0A%09%09%09move();%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add second, less elegant solution for assignment 1, problem 4