안녕하세요
문제중에서 robot을 골까지 벽에 충돌하지 않고 보내는게 있는데 do....while 을 써야 할 것 같은데
public class DumboController
{
public void controlRobot(IRobot robot)
{
int randno;
int direction;
// Select a random number
randno = (int) Math.round(Math.random()*3);
// Convert this to a direction
do
{
if (randno == 0)
{
direction = IRobot.AHEAD;
}
else if (randno == 1)
{
direction = IRobot.RIGHT;
}
else if (randno == 2)
{
direction = IRobot.BEHIND;
}
else
{
direction = IRobot.LEFT;
}
}
while (robot.look(direction) == IRobot.WALL);
robot.face(direction);
// Face the robot in this direction
robot.advance();
// and move the robot
}
}
여기서 do 안에 있는 statement가 반복되어야 robot이 계속 움직여서 골까지 들어갈텐데
어떻게 해야할지 모르겠네요...
답변 부탁드립니다..
첫댓글 질문을 상세하게 다시 하시고, full소스 올려보시죠. 분명 여러고수분들이 도와주실거임