Browse Source

add setState

fleetstorm
Max Wenzel 3 years ago
committed by Lorenz Hohmann
parent
commit
10c4518ed0
  1. 4
      src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java
  2. 19
      src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java

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

@ -27,4 +27,8 @@ public class Coordinate {
public int getState() {
return this.state;
}
public void setState(int state) {
this.state = state;
}
}

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

@ -22,4 +22,23 @@ class CoordinateTest {
assertEquals(coordinate.getState(), Coordinate.EMPTY);
assertEquals(coordinate.getState(), 0);
}
@Test
void testGetAndSetForAllStates() {
coordinate.setState(Coordinate.SHIP);
assertEquals(coordinate.getState(), Coordinate.SHIP);
assertEquals(coordinate.getState(), 1);
coordinate.setState(Coordinate.SHOT);
assertEquals(coordinate.getState(), Coordinate.SHOT);
assertEquals(coordinate.getState(), 2);
coordinate.setState(Coordinate.HIT);
assertEquals(coordinate.getState(), Coordinate.HIT);
assertEquals(coordinate.getState(), 3);
coordinate.setState(Coordinate.EMPTY);
assertEquals(coordinate.getState(), Coordinate.EMPTY);
assertEquals(coordinate.getState(), 0);
}
}
Loading…
Cancel
Save