From 9a1f3669da7f2b93851a61441e8cb82e00820bb8 Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Thu, 13 Jan 2022 13:34:41 +0100 Subject: [PATCH] Refactoring: setLastShot() doesn't need param matchfield anymore --- src/main/java/de/tims/fleetstorm/ai/Logic.java | 4 ++-- src/test/java/de/tims/fleetstorm/ai/LogicTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/tims/fleetstorm/ai/Logic.java b/src/main/java/de/tims/fleetstorm/ai/Logic.java index e6547ee..e80125d 100644 --- a/src/main/java/de/tims/fleetstorm/ai/Logic.java +++ b/src/main/java/de/tims/fleetstorm/ai/Logic.java @@ -38,8 +38,8 @@ public class Logic { return out; } - public void setLastShot(Coordinate coordinate, Matchfield matchfield) { - lastShot = matchfield.getField(coordinate); + public void setLastShot(Coordinate coordinate) { + lastShot = this.matchfield.getField(coordinate); } diff --git a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java index 8fafc91..0c47f54 100644 --- a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java +++ b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java @@ -74,9 +74,10 @@ class LogicTest { int size = 4; matchfield = new Matchfield(size); matchfield.createMatchfield(); + logic.setMatchfield(matchfield); Coordinate expectedResult = new Coordinate(2, 2); - logic.setLastShot(expectedResult, matchfield); + logic.setLastShot(expectedResult); Coordinate result = logic.getLastShot(); assertEquals(result, expectedResult); @@ -96,7 +97,6 @@ class LogicTest { logic.setMatchfield(matchfield); result = logic.getMatchfield(); assertNotNull(result); - } }