« CS106A: Programming Methodology Assignment 1.3 | Main | CS106A: Programming Methodology Assignment 1.1 »
Wednesday
Dec052012

CS106A: Programming Methodology Assignment 1.2

import stanford.karel.*;

public class StoneMasonKarel extends SuperKarel {

	public void run() {
		turnLeft();
		repairColumn();
		while (frontIsClear()){
		nextColumn();
		repairColumn();
		}
	}

	private void repairColumn() {
		
	while (frontIsClear())	{
		if (noBeepersPresent()){
			putBeeper();
		}
		move ();	
	}
	if (noBeepersPresent()){
		putBeeper();
	}
	
	//Descend the column
	turnAround();
	while(frontIsClear()){
		move();
	}
	turnLeft();
	
	}
	
	private void nextColumn() {	
		//Move to next column
		move();
		move();
		move();
		move();
		turnLeft();
	}
	

	
}