Browse Source

add DeafaultState(EMPTY) to Coordinate

Max Wenzel 3 years ago
parent
commit
8299c8affc
  1. 10
      src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java
  2. 5
      src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java

10
src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java

@ -3,10 +3,17 @@ package de.tims.fleetstorm.matchfield;
public class Coordinate { public class Coordinate {
private int x; private int x;
private int y; private int y;
private int state;
public static final int EMPTY = 0;
public static final int SHIP = 1;
public static final int SHOT = 2;
public static final int HIT = 3;
public Coordinate(int x, int y) { public Coordinate(int x, int y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.state = 0;
} }
public Integer getX() { public Integer getX() {
@ -17,4 +24,7 @@ public class Coordinate {
return y; return y;
} }
public int getState() {
return this.state;
}
} }

5
src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java

@ -17,4 +17,9 @@ class CoordinateTest {
assertEquals(coordinate.getY(), y); assertEquals(coordinate.getY(), y);
} }
@Test
void testCoordinatehasDefaultStates() {
assertEquals(coordinate.getState(), Coordinate.EMPTY);
assertEquals(coordinate.getState(), 0);
}
} }
Loading…
Cancel
Save