Beruflich Dokumente
Kultur Dokumente
MAMPAN SANGSA
ID: 50052535
1)
Code
import stanford.karel.Karel;
/**
*/
/**
* @author 50052535
*
*/
/**
* @param args
*/
turnLeft();
putBeeper();
while (frontIsClear()) {
move();
if (noBeepersPresent()) {
putBeeper();
turnRight();
move();
turnRight();
putBeeper();
while (frontIsClear()) {
move();
if (noBeepersPresent()) {
putBeeper();
turnLeft();
move();
turnLeft();
putBeeper();
while (frontIsClear()) {
move();
if (noBeepersPresent()) {
putBeeper();
turnRight();
turnRight();
while (frontIsClear()) {
move();
if (noBeepersPresent()) {
putBeeper();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
}
ขันตอนต่
้ อไป
2)
โค้ ด
import stanford.karel.Karel;
/**
*/
/**
* @author 50052535
*/
/**
* @param args
*/
move();
pickBeeper();
fillPothole();
move();
turnRight();
move();
putBeeper();
turnAround();
move();
turnRight();
move();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
}
ขันตอนต่
้ อไป
3)
โค้ ด
import stanford.karel.Karel;
/**
*/
/**
* @author 50052535
*/
/**
* @param args
*/
while (frontIsClear()) {
move();
if (noBeepersPresent()) {
if (beepersInBag()) {
putBeeper();
if (frontIsBlocked()) {
turnLeft();
}
ขันตอนต่
้ อไป
4)
Code
import stanford.karel.Karel;
/**
*/
/**
* @author 50052535
*/
* @param args
*/
claimUp();
move();
move();
move();
jumpUp();
putBeeper();
move();
jumpDown();
move();
move();
claimDown();
move();
move();
while (frontIsClear()) {
move();
putBeeper();
turnAround();
move();
turnRight();
move();
turnRight();
}
public void turnRight() {
turnLeft();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
turnLeft();
move();
turnRight();
move();
turnRight();
move();
turnLeft();
move();
turnRight();
move();
turnRight();
move();
putBeeper();
turnAround();
move();
ขันตอนต่
้ อไป
5)
โค้ ด
import stanford.karel.Karel;
/**
*/
/**
* @author 50052535
*
*/
/**
* @param args
*/
move();
claimUp();
claimDown();
if (frontIsBlocked()) {
if (rightIsBlocked()) {
turnLeft();
}
}
if (rightIsClear()) {
putBeeper();
move();
putBeeper();
turnRight();
move();
putBeeper();
turnRight();
move();
putBeeper();
turnLeft();
turnLeft();
turnLeft();
ขันต่
้ อนต่อไป