Rover has an starting direction
This commit is contained in:
parent
d5388d1e3c
commit
8ff890376b
|
@ -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}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue