Checkerboard

0

java

목록 보기
3/11
post-thumbnail

import stanford.karel.*;

public class CheckerboardKarel extends SuperKarel {

public void run(){
	putBeeper();
	seedRight();
}

private void seedRight(){
	gotoWall();
	turnLeft();
	if (frontIsClear()){
		jummpNextLine();
		turnLeft();
		seedLeft();
	}
}

private void seedLeft(){
	gotoWall();
	turnRight();
	if (frontIsClear()){
		jummpNextLine();
		turnRight();
		seedRight();
	}
}


private void jummpNextLine(){
	if (beepersPresent()){
		move();	
	}
	else {
		move();
		putBeeper();
	}
}

private void gotoWall(){
	while (frontIsClear()){
		if (beepersPresent()){
			move();
		}
		else {
			move();
			putBeeper();
		}
	}
}

}

profile
초보 데이터분석가의 기록 공간입니다 😁

0개의 댓글