Browse Source

Refactoring: boolean foundShip is private now

fleetstorm
Max Wenzel 3 years ago
committed by Lorenz Hohmann
parent
commit
e064873635
  1. 11
      src/main/java/de/tims/fleetstorm/ai/Logic.java
  2. 9
      src/test/java/de/tims/fleetstorm/ai/LogicTest.java

11
src/main/java/de/tims/fleetstorm/ai/Logic.java

@ -10,7 +10,7 @@ public class Logic {
private Matchfield matchfield;
private Coordinate lastShot;
public boolean foundShip = false;
private boolean foundShip = false;
public Coordinate chooseField() {
ArrayList<Coordinate> possibleFields = new ArrayList<Coordinate>();
@ -66,4 +66,13 @@ public class Logic {
System.out.println("Do this");
}
public void setFoundShip(boolean b) {
this.foundShip = b;
}
public boolean getFoundShip() {
// TODO Auto-generated method stub
return this.foundShip;
}
}

9
src/test/java/de/tims/fleetstorm/ai/LogicTest.java

@ -114,7 +114,14 @@ class LogicTest {
logic.setLastShot(new Coordinate(2, 2));
logic.getLastShot().setState(Coordinate.HIT);
logic.findShip();
assertEquals(logic.foundShip, true);
assertEquals(logic.getFoundShip(), true);
}
@Test
void testGetAndsetFoundShip() {
Logic logic = new Logic();
logic.setFoundShip(true);
assertEquals(logic.getFoundShip(), true);
}
}
Loading…
Cancel
Save