//            abstractDirection = AbstractRobot.Direction.UP;
public void fillPath(DirectionRobot robot, int endX, int endY) {
        int width = robot.getX() - endX;
        int height = robot.getY() - endY;
        //todo refactor logic
        //select direction
        AbstractRobot.Direction abstractDirection = robot.getDirection();
        System.out.println("first!");
        if (width < 0) {
            //start on the left side
            switch (abstractDirection) {
                case UP: {
                    this.addComand(new RotateRightComand(robot));
                }
                break;
                case LEFT: {
                    this.addComand(new RotateRightComand(robot));
                    this.addComand(new RotateRightComand(robot));
                }
                break;
                case DOWN: {
                    this.addComand(new RotateLeftComand(robot));
                }
                break;
            }
            abstractDirection = AbstractRobot.Direction.RIGHT;
        }
        if (width > 0) {
            //start on the right side
            switch (abstractDirection) {
                case UP: {
                    this.addComand(new RotateLeftComand(robot));
                }
                break;
                case DOWN: {
                    this.addComand(new RotateRightComand(robot));
                }
                break;
                case RIGHT: {
                    this.addComand(new RotateLeftComand(robot));
                    this.addComand(new RotateLeftComand(robot));
                }
                break;
            }
            abstractDirection = AbstractRobot.Direction.LEFT;
        }
        //move X
        System.out.println(width);
        for (int i = 0; i < abs(width); i++) {
            this.addComand(new MoveForwardComand(robot));
        }
        //select direction again
        if (height < 0) {
            //if start above end
            switch (abstractDirection) {
                case LEFT: {
                    this.addComand(new RotateLeftComand(robot));
                }
                break;
                case RIGHT: {
                    this.addComand(new RotateRightComand(robot));
                }
                break;
            }
//            abstractDirection = AbstractRobot.Direction.DOWN;
        }
        if (height > 0) {
            //if start below end
            switch (abstractDirection) {
                case LEFT: {
                    this.addComand(new RotateRightComand(robot));
                }
                break;
                case RIGHT: {
                    this.addComand(new RotateLeftComand(robot)); //done
                }
                break;
            }
//            abstractDirection = AbstractRobot.Direction.UP;
        }
        //move Y
        System.out.println(height);
        for (int i = 0; i < abs(height); i++) {
            this.addComand(new MoveForwardComand(robot));
        }
    }
break;
}
// abstractDirection = AbstractRobot.Direction.UP;
}
//move Y
switch (abstractDirection) {
case LEFT: {
this.addComand(new RotateRightComand(robot));
}
break;
case RIGHT: {
this.addComand(new RotateLeftComand(robot)); //done
}
break;
}
// abstractDirection = AbstractRobot.Direction.UP;
}
//move Y
System.out.println(height);
for (int i = 0; i < abs(height); i++) {
this.addComand(new MoveForwardComand(robot));
}
}
break;
case RIGHT: {
this.addComand(new RotateRightComand(robot));
}
break;
}
// abstractDirection = AbstractRobot.Direction.DOWN;
}
if (height > 0) {
//if start below end
switch (abstractDirection) {
case LEFT: {
this.addComand(new RotateRightComand(robot));
}
break;
case RIGHT: {
this.addComand(new RotateLeftComand(robot)); //done
}
break;
}
// abstractDirection = AbstractRobot.Direction.UP;
}
//move Y
System.out.println(height);
for (int i = 0; i < abs(height); i++) {
this.addComand(new MoveForwardComand(robot));
}
}