Skip to content

Commit

Permalink
fixed problems
Browse files Browse the repository at this point in the history
  • Loading branch information
skviropitek committed May 7, 2024
1 parent 83f76c7 commit dc31009
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/core/basesyntax/RobotRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ public void moveRobot(Robot robot, int toX, int toY) {
while (robot.getDirection() != Direction.LEFT) {
robot.turnLeft();
}
} else if (currentY < toY) {
}
while (robot.getX() != toX) {
robot.stepForward();
}
if (currentY < toY) {
while (robot.getDirection() != Direction.UP) {
robot.turnLeft();
}
Expand All @@ -21,10 +25,8 @@ public void moveRobot(Robot robot, int toX, int toY) {
robot.turnLeft();
}
}
while (robot.getX() != toX || robot.getY() != toY) {
while (robot.getY() != toY) {
robot.stepForward();
currentX = robot.getX();
currentY = robot.getY();
}
}
}

0 comments on commit dc31009

Please sign in to comment.