Assignment1_CollectNewspaperKarel

来源:互联网 发布:童年阴影知乎 编辑:程序博客网 时间:2024/05/01 18:57
/*
 * File: CollectNewspaperKarel.java
 * --------------------------------
 * At present, the CollectNewspaperKarel subclass does nothing.
 * Your job in the assignment is to add the necessary code to
 * instruct Karel to walk to the door of its house, pick up the
 * newspaper (represented by a beeper, of course), and then return
 * to its initial position in the upper left corner of the house.
 */


import stanford.karel.*;


/*
 * Name: 
 * Section Leader: 
 */


public class CollectNewspaperKarel extends SuperKarel {


public void run() {
// You fill in this part
turnRight();
move();
turnLeft();
while (noBeepersPresent())
move();
pickBeeper();
turnAround();
while (frontIsClear())
move();
turnRight();
move();
turnRight();
}


}
原创粉丝点击