CollectNewspaper

0

java

목록 보기
1/11
post-thumbnail

import stanford.karel.*;

public class CollectNewspaperKarel extends SuperKarel {

public void run() {
	movetoWall();
	turnRight();
	findBeeper();
	pickBeeper();
	gobackHome();
	turnRight();
}

private void movetoWall() {
	while(frontIsClear()) {
		move();
	}
}

private void findBeeper() {
	move();
	if (leftIsClear()) {
		turnLeft();
		move();
	} else {
		movetoWall();
	}
}

private void gobackHome() {
	turnAround();
	movetoWall();
	turnRight();
	movetoWall();
}

}

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

0개의 댓글