1
0
Fork 0
mars-rover-kata/src/main/java/cat/hack3/codingtests/marsrover/MarsMap.java

24 lines
618 B
Java

package cat.hack3.codingtests.marsrover;
import static cat.hack3.codingtests.marsrover.MarsMap.Direction.*;
public class MarsMap {
public enum Direction {NORTH, SOUTH, EAST, WEST}
private final int width;
private final int height;
public MarsMap(int width, int height) {
this.width = width;
this.height = height;
}
public Direction changeDirectionToLeft(Direction currentDirection) {
return switch (currentDirection) {
case NORTH -> WEST;
case SOUTH -> EAST;
case EAST -> NORTH;
case WEST -> SOUTH;
};
}
}