Skip to content

Commit

Permalink
release RobotRoute classg
Browse files Browse the repository at this point in the history
  • Loading branch information
u3IOm4uk committed Dec 17, 2023
1 parent 7487272 commit 405ade0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/core/basesyntax/RobotRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
public class RobotRoute {
public void moveRobot(Robot robot, int toX, int toY) {
//write your solution here
while (robot.getX() > toX && robot.getDirection() == Direction.RIGHT) {
while (robot.getX() > toX && robot.getDirection() != Direction.LEFT) {
robot.turnLeft();
}
while (robot.getX() < toX && robot.getDirection() == Direction.LEFT) {
while (robot.getX() < toX && robot.getDirection() != Direction.RIGHT) {
robot.turnRight();
}
while (robot.getX() != toX) {
robot.stepForward();
}
while (robot.getY() > toY && robot.getDirection() == Direction.UP) {
while (robot.getY() > toY && robot.getDirection() != Direction.DOWN) {
robot.turnLeft();
}
while (robot.getY() < toY && robot.getDirection() == Direction.DOWN) {
while (robot.getY() < toY && robot.getDirection() != Direction.UP) {
robot.turnRight();
}
while (robot.getY() != toY) {
Expand Down

0 comments on commit 405ade0

Please sign in to comment.