From 5ac2074484aaf1e9ef63fcdfffd689ebd98eaaef Mon Sep 17 00:00:00 2001 From: Rafal Date: Sat, 22 Jun 2024 17:17:43 +0200 Subject: [PATCH] new condition added --- src/main/java/core/basesyntax/RobotRoute.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/core/basesyntax/RobotRoute.java b/src/main/java/core/basesyntax/RobotRoute.java index f1a1b95f..d2bb67aa 100644 --- a/src/main/java/core/basesyntax/RobotRoute.java +++ b/src/main/java/core/basesyntax/RobotRoute.java @@ -15,7 +15,7 @@ public void moveRobot(Robot robot, int toX, int toY) { while (robot.getDirection() != Direction.LEFT) { robot.turnRight(); } - while (robot.getDirection() == Direction.LEFT) { + while (robot.getDirection() == Direction.LEFT && robot.getX() != toX ) { robot.stepForward(); } } else { @@ -32,7 +32,7 @@ public void moveRobot(Robot robot, int toX, int toY) { while (robot.getDirection() != Direction.UP) { robot.turnLeft(); } - while (robot.getDirection() == Direction.UP) { + while (robot.getDirection() == Direction.UP && robot.getY() != toY) { robot.stepForward(); } } else {