Browse Source

add Matchfield variable with Getter/Setter in ai-logic

Max Wenzel 3 years ago
parent
commit
fa329801f1
  1. 10
      src/main/java/de/tims/fleetstorm/ai/Logic.java
  2. 16
      src/test/java/de/tims/fleetstorm/ai/LogicTest.java

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

@ -8,6 +8,7 @@ import de.tims.fleetstorm.matchfield.Matchfield;
public class Logic {
private Matchfield matchfield;
private Coordinate lastShot;
public Coordinate chooseField(Matchfield matchfield) {
@ -46,4 +47,13 @@ public class Logic {
return lastShot;
}
public void setMatchfield(Matchfield matchfield) {
this.matchfield = matchfield;
}
public Matchfield getMatchfield() {
return matchfield;
}
}

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

@ -83,4 +83,20 @@ class LogicTest {
}
@Test
void testSetMatchfield() {
Logic logic = new Logic();
Matchfield matchfield;
int size = 4;
matchfield = new Matchfield(size);
matchfield.createMatchfield();
Matchfield result = logic.getMatchfield();
assertEquals(result, null);
logic.setMatchfield(matchfield);
result = logic.getMatchfield();
assertNotNull(result);
}
}
Loading…
Cancel
Save