Skip to content

Commit

Permalink
moved down int currentY to its first usage
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksiiBashkirov committed Jan 26, 2024
1 parent fc45e77 commit b3af531
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/core/basesyntax/RobotRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public class RobotRoute {
public void moveRobot(Robot robot, int toX, int toY) {
int currentX = robot.getX();
int currentY = robot.getY();
int deltaX = toX - currentX;
while (deltaX > 0 && robot.getDirection() != Direction.RIGHT) {
robot.turnRight();
Expand All @@ -14,6 +13,7 @@ public void moveRobot(Robot robot, int toX, int toY) {
while (robot.getX() != toX) {
robot.stepForward();
}
int currentY = robot.getY();
int deltaY = toY - currentY;
while (deltaY > 0 && robot.getDirection() != Direction.UP) {
robot.turnRight();
Expand Down

0 comments on commit b3af531

Please sign in to comment.