An Example of Stepwise Refinement(BanishWinter)
来源:互联网 发布:在淘宝上买匕首犯法吗 编辑:程序博客网 时间:2024/06/06 00:58
import stanford.karel.*;
public class BanishWinter extends SuperKarel {
public void run() {
while (beepersInBag()) {
moveToTree();
climbTree();
putDownBeeper();
toBottom();
}
}
private void moveToTree() {
while (frontIsClear())
move();
}
private void climbTree() {
while (frontIsBlocked()) {
turnLeft();
move();
turnRight();
}
}
private void putDownBeeper() {
turnLeft();
putTwoBeeper();
turnRight();
move();
turnRight();
putTwoBeeper();
}
private void putTwoBeeper() {
putBeeper();
move();
putBeeper();
}
private void toBottom() {
while (frontIsClear())
move();
turnLeft();
}
}
public class BanishWinter extends SuperKarel {
public void run() {
while (beepersInBag()) {
moveToTree();
climbTree();
putDownBeeper();
toBottom();
}
}
private void moveToTree() {
while (frontIsClear())
move();
}
private void climbTree() {
while (frontIsBlocked()) {
turnLeft();
move();
turnRight();
}
}
private void putDownBeeper() {
turnLeft();
putTwoBeeper();
turnRight();
move();
turnRight();
putTwoBeeper();
}
private void putTwoBeeper() {
putBeeper();
move();
putBeeper();
}
private void toBottom() {
while (frontIsClear())
move();
turnLeft();
}
}
- An Example of Stepwise Refinement(BanishWinter)
- an example of repeater
- an example of using automake.
- An Example of association query
- An example of responseXML.getElementsByTagName
- An example of using Thrift
- an example of enhancement framework
- An Entry Example of Log4j
- An easy example of using AJAX
- An example of lib3ds 2.0 with opengl32
- An Example of Perl Multi-thread 2
- an example of use namespace for encapsulation
- An example of using STL multimap
- An Example of Hadoop MapReduce Counter
- An Example of How Oracle Works
- An example of Integrating Spark and Cassandra
- an example of maven-bundle-plugin
- Django: An example of Django template
- ping命令的实现
- 关于myeclipse10.0 的jsp中某个标签中 javascript (代码正常)事件的错误提示。
- HTML 第一节课
- 我为VB打抱不平--"一通百通 语言就是纸老虎"
- java调用sharepoint webservice
- An Example of Stepwise Refinement(BanishWinter)
- Net 类库开发的设计准则
- MFC使用SkinMagic使用详解【中级】
- Buddy System,伙伴系统
- C# 等号两边执行顺序
- 用数组模拟链表
- JS保留两位小数 四舍五入函数
- NASM IDE开发环境
- 要****成功的方法