Getting stuck ?!?

stuck!


* 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(){
		while(frontIsClear()){
			turnLeft();
			movetowall();
			keepmoving();
		}
	}
	
	private void movetowall(){
		while(frontIsClear()){
			move();
		}
	}

	private void keepmoving(){
		if(notFacingEast()){
			turnRight();
		}
		nextcolumn();
	}
	
	private void fixColumn(){
		while(noBeepersPresent()){
			putBeeper();
			move();
		}
		backtostart();
	}
	
	private void nextcolumn(){
		turnRight();
		move();
		turnLeft();
//		turnLeft();
//		move();
	}
	
	private void backtostart(){
		turnAround();
		movetowall();
		turnAround();
	}
	
	private void check(){
		while(noBeepersPresent()){
			move();
		}
		//backtostart();
	}
//	private void fix(){		
//		if(beepersPresent()){
//			//backtostart();
//			fixColumn();
			
//			turnAround();
//			movetowall();
//		}
		
//	}

}



how to iterate??

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.