/* * File: StoneMasonKarel.java * -------------------------- * The StoneMasonKarel subclass as it appears here does nothing. * When you finish writing it, it should solve the "repair the quad" * problem from Assignment 1. In addition to editing the program, * you should be sure to edit this comment so that it no longer * indicates that the program does nothing. */ import stanford.karel.*; public class StoneMasonKarel extends SuperKarel { public void run() { // 1st column is allways at starting point while( frontIsClear() ) { repairColumn(); walkNext(); } repairColumn(); } private void repairColumn() { /* Climbs a Columne and fixes it. Falls back down when done. * facing EAST again. */ turnLeft(); while( frontIsClear() ) { if( noBeepersPresent() ) { putBeeper(); } move(); } // Front is now blocked (top on column), drop another beeper if needed. if( noBeepersPresent() ) { putBeeper(); } turnAround(); moveToWall(); turnLeft(); } private void moveToWall() { // Moves Karel all the way straight forward until aproaching a wall while( frontIsClear() ) { move(); } } private void walkNext() { /* walks 4 steps forward */ for( int x=0; x < 4 ; x++ ) { move(); } } }