Код: Выделить всё
public void deploy(){
while (true) {
if (isFrontClear() && !isBoundary()) {
move();
System.out.println("basic moving");
while(isFacingNorth() || isFacingSouth() || isFacingWest()){
System.out.println("entering first while loop");
if(!isBottomWall() && isFrontClear() || !isBottomWall() && isFrontWall()){
turnRight();
move();
}
if (isBottomWall() && isFrontClear()) {
move();
while(isFacingEast() || isFacingNorth()){
System.out.println("entering if state in for loop");
System.out.println("entering do while");
if (isFrontWall() && isBottomWall()){
turnLeft();
System.out.println("turningLeft");
} else if (isBottomWall() && isFrontClear()){
move();
System.out.println("moving");
} else {
turnRight();
move();
}
}
} else if(isBottomWall() && isFrontWall()){
turnLeft();
} else {
break;
}
}
} else if (isFrontWall() && !isBoundary()) {
turnLeft();
System.out.println("basicturnLeft");
} else {
break;
}
}
}
public void task(){
deploy();
}
public static void main(String[] args) {
Boxing boxy = new Boxing();
boxy.runTask();
}
Я получил вложенные циклы, все условия работают, за исключением того, что он пропускает какое-либо поведение, как будто он должен выполнять оператор условия внутри цикла while, но выполняет только внешний условный оператор
Подробнее здесь: https://stackoverflow.com/questions/789 ... on-process