1
0
Fork 0

Rover has an starting direction

This commit is contained in:
Xavier Fontanet 2024-06-20 14:52:41 +02:00
parent d5388d1e3c
commit 8ff890376b
3 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,13 @@
package cat.hack3.codingtests.marsrover; package cat.hack3.codingtests.marsrover;
public class MarsMap { public class MarsMap {
private final int width;
private final int height;
public MarsMap(int width, int height) { public MarsMap(int width, int height) {
this.width = width;
this.height = height;
} }
public enum Direction {NORTH, SOUTH, EAST, WEST}
} }

View File

@ -5,7 +5,7 @@ public class MarsRover {
private final int latitudeStartingPoint; private final int latitudeStartingPoint;
private final int longitudeStartingPoint; private final int longitudeStartingPoint;
public MarsRover(MarsMap marsMap, int latitudeStartingPoint, int longitudeStartingPoint) { public MarsRover(MarsMap marsMap, int latitudeStartingPoint, int longitudeStartingPoint, MarsMap.Direction startingDirection) {
this.marsMap = marsMap; this.marsMap = marsMap;
this.latitudeStartingPoint = latitudeStartingPoint; this.latitudeStartingPoint = latitudeStartingPoint;
this.longitudeStartingPoint = longitudeStartingPoint; this.longitudeStartingPoint = longitudeStartingPoint;

View File

@ -3,6 +3,8 @@ package cat.hack3.codingtests.marsrover;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static cat.hack3.codingtests.marsrover.MarsMap.Direction.SOUTH;
public class MarsRoverTest { public class MarsRoverTest {
public static final int MAP_WIDTH = 10; public static final int MAP_WIDTH = 10;
@ -15,9 +17,10 @@ public class MarsRoverTest {
} }
@Test @Test
public void havingARoverWithStartingPoint() { public void havingARoverWithStartingPointAndDirection() {
int latitudeStartingPoint = 2; int latitudeStartingPoint = 2;
int longitudeStartingPoint = 3; int longitudeStartingPoint = 3;
new MarsRover(marsMap, latitudeStartingPoint, longitudeStartingPoint); MarsMap.Direction startingDirection = SOUTH;
new MarsRover(marsMap, latitudeStartingPoint, longitudeStartingPoint, startingDirection);
} }
} }