CS106A编程方法学二

机器人卡雷尔的四个指令:

 

 move();       //向前移一格;
turnLeft(); //向左转;
pcickBeeper(); //捡起方块;
putBeeper();//放下方块;

定义向右转

public void turnRight()
{
turnLeft();
turnLeft();
turnLeft();
}

向右转(循环)

//for循环
for(int i=0;i<3;i++)
{
turnLeft();
}


if-else

if(beepers present())
{
if(frontIscearl)
{
move();
}
}
else
{
putBeeper();
}




posted @ 2012-03-17 19:34  逍游  阅读(152)  评论(1编辑  收藏  举报