diff --git a/.idea/hellsgamers.iml b/.idea/hellsgamers.iml index 72c76be..74774b6 100644 --- a/.idea/hellsgamers.iml +++ b/.idea/hellsgamers.iml @@ -14,13 +14,13 @@ - - + + - + - - - + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_9_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_8_1.xml similarity index 58% rename from .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_9_2.xml rename to .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_8_1.xml index 1b189a7..987e7d4 100644 --- a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_9_2.xml +++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_8_1.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_9_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_8_1.xml similarity index 55% rename from .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_9_2.xml rename to .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_8_1.xml index e5cf963..4910ca9 100644 --- a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_9_2.xml +++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_8_1.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_9_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_8_1.xml similarity index 65% rename from .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_9_2.xml rename to .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_8_1.xml index b181218..85ab9ad 100644 --- a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_9_2.xml +++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_8_1.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_9_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_8_1.xml similarity index 65% rename from .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_9_2.xml rename to .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_8_1.xml index 3ee66e9..8675273 100644 --- a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_9_2.xml +++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_8_1.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_9_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_8_1.xml similarity index 65% rename from .idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_9_2.xml rename to .idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_8_1.xml index 38b9aa2..3417208 100644 --- a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_9_2.xml +++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_8_1.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_9_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_8_1.xml similarity index 65% rename from .idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_9_2.xml rename to .idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_8_1.xml index ecbd84e..f19b408 100644 --- a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_9_2.xml +++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_8_1.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0acf85b..45a3e86 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,20 @@ 17 + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + false + + + + + + junit @@ -22,7 +36,7 @@ org.junit.jupiter junit-jupiter - RELEASE + 5.8.1 test diff --git a/src/main/java/PingPong/GamePanel.java b/src/main/java/PingPong/GamePanel.java index d731f9b..d9e8dc6 100644 --- a/src/main/java/PingPong/GamePanel.java +++ b/src/main/java/PingPong/GamePanel.java @@ -98,10 +98,6 @@ public class GamePanel extends JPanel implements Runnable { } } - - - - public void run() { long lastTime = System.nanoTime(); double amountOfTicks = 60.0; diff --git a/src/test_/java/CollisionCheckerTest.java b/src/test_/java/CollisionCheckerTest.java new file mode 100644 index 0000000..767bda1 --- /dev/null +++ b/src/test_/java/CollisionCheckerTest.java @@ -0,0 +1,124 @@ +import PingPong.CollisionChecker; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.awt.*; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + + + class CollisionCheckerTest { + CollisionChecker collisionChecker; + + @BeforeEach + public void before() { + collisionChecker = new CollisionChecker(); + } + @Test + void WhenBallYCoordinateIsLessOrEqualThanZero_didTouchTopOrBottomEdge_ReturnsTrue() { + // arrange + Integer ballYCoordinate = -1; + Integer maxHeight = 123; + + // act + Boolean result = collisionChecker.didTouchTopOrBottomEdge(ballYCoordinate, maxHeight); + + //assert + assertTrue(result); + } + @Test + void WhenBallYCoordinateIsMoreOrEqualToMaxHeight_didTouchTopOrBottomEdge_ReturnsTrue() { + // arrange + Integer ballYCoordinate = 124; + Integer maxHeight = 123; + + // act + Boolean result = collisionChecker.didTouchTopOrBottomEdge(ballYCoordinate, maxHeight); + + //assert + assertTrue(result); + } + @Test + void WhenBallYCoordinateIsMoreThanZeroAndLessThanMaxHeight_didTouchTopOrBottomEdge_ReturnsFalse() { + // arrange + Integer ballYCoordinate = 75; + Integer maxHeight = 123; + + // act + Boolean result = collisionChecker.didTouchTopOrBottomEdge(ballYCoordinate, maxHeight); + + //assert + assertFalse(result); + } + @Test + void WhenBallRectangleIntersectsWithPaddleRectangle_didTouchPaddle_ReturnsTrue() { + // arrange + Rectangle ballRectangle = new Rectangle(1,1,1,1); + Rectangle paddleRectangle = new Rectangle(1,1,5,5); + + //act + Boolean result = collisionChecker.didTouchPaddle(ballRectangle, paddleRectangle); + + //assert + assertTrue(result); + } + @Test + void WhenBallRectangleDoesNotIntersectsWithPaddleRectangle_didTouchPaddle_ReturnsFalse() { + // arrange + Rectangle ballRectangle = new Rectangle(1,1,1,1); + Rectangle paddleRectangle = new Rectangle(15,15,1,1); + + //act + Boolean result = collisionChecker.didTouchPaddle(ballRectangle, paddleRectangle); + + //assert + assertFalse(result); + } + @Test + void WhenBallXCoordinateIsLessOrEqualThanZero_didTouchLeftEdge_ReturnsTrue() { + // arrange + Integer ballXCoordinate = -5; + + //act + Boolean result = collisionChecker.didTouchLeftEdge(ballXCoordinate); + + //assert + assertTrue(result); + } + @Test + void WhenBallXCoordinateIsMoreThanZero_didTouchLeftEdge_ReturnsTrue() { + // arrange + Integer ballXCoordinate = 10; + + //act + Boolean result = collisionChecker.didTouchLeftEdge(ballXCoordinate); + + //assert + assertFalse(result); + } + @Test + void WhenBallXCoordinateIsMoreOrEqualToMaxWidth_didTouchRightEdge_ReturnsTrue() { + // arrange + Integer ballXCoordinate = 124; + Integer maxWidth = 123; + + // act + Boolean result = collisionChecker.didTouchRightEdge(ballXCoordinate, maxWidth); + + //assert + assertTrue(result); + } + @Test + void WhenBallXCoordinateIsLessThanMaxWidth_didTouchRightEdge_ReturnsFalse() { + // arrange + Integer ballXCoordinate = 75; + Integer maxWidth = 123; + + // act + Boolean result = collisionChecker.didTouchRightEdge(ballXCoordinate, maxWidth); + + //assert + assertFalse(result); + } +} diff --git a/target/classes/BattleShip/BShip$IncomingGuessReader.class b/target/classes/BattleShip/BShip$IncomingGuessReader.class new file mode 100644 index 0000000..a8f7d4c Binary files /dev/null and b/target/classes/BattleShip/BShip$IncomingGuessReader.class differ diff --git a/target/classes/BattleShip/BShip$ShipsPlacedReader.class b/target/classes/BattleShip/BShip$ShipsPlacedReader.class new file mode 100644 index 0000000..1893eb1 Binary files /dev/null and b/target/classes/BattleShip/BShip$ShipsPlacedReader.class differ diff --git a/target/classes/PingPong/GamePanel$AL.class b/target/classes/PingPong/GamePanel$AL.class index 8592c1a..38e42d2 100644 Binary files a/target/classes/PingPong/GamePanel$AL.class and b/target/classes/PingPong/GamePanel$AL.class differ diff --git a/target/classes/PingPong/GamePanel.class b/target/classes/PingPong/GamePanel.class index 194c31a..5dd0342 100644 Binary files a/target/classes/PingPong/GamePanel.class and b/target/classes/PingPong/GamePanel.class differ diff --git a/target/classes/classpath.index b/target/classes/classpath.index new file mode 100644 index 0000000..e5601ba Binary files /dev/null and b/target/classes/classpath.index differ diff --git a/target/hellsgamers-1.0-SNAPSHOT.jar b/target/hellsgamers-1.0-SNAPSHOT.jar index ea3a279..0adfec4 100644 Binary files a/target/hellsgamers-1.0-SNAPSHOT.jar and b/target/hellsgamers-1.0-SNAPSHOT.jar differ diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties index e6bd5fe..a3f66d2 100644 --- a/target/maven-archiver/pom.properties +++ b/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Wed Feb 08 20:10:52 CET 2023 +#Wed Feb 08 21:32:53 CET 2023 groupId=Hellsgamers artifactId=hellsgamers version=1.0-SNAPSHOT diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 3ecedd5..c11ae49 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -21,6 +21,8 @@ BattleShip\AIGridGUI$DirectionCompare.class BattleShip\AIGridGUI.class Snake\Snake$SnakeDirection.class Snake\SnakeView.class +BattleShip\BShip$IncomingGuessReader.class +BattleShip\BShip$ShipsPlacedReader.class Snake\AppleView.class Snake\Controller$3.class Snake\TextView.class diff --git a/target/test-classes/BShipTest.class b/target/test-classes/BShipTest.class new file mode 100644 index 0000000..277a7c9 Binary files /dev/null and b/target/test-classes/BShipTest.class differ diff --git a/target/test-classes/CollisionCheckerTest.class b/target/test-classes/CollisionCheckerTest.class new file mode 100644 index 0000000..15f75ac Binary files /dev/null and b/target/test-classes/CollisionCheckerTest.class differ diff --git a/target/test-classes/ShipTest.class b/target/test-classes/ShipTest.class new file mode 100644 index 0000000..2f24884 Binary files /dev/null and b/target/test-classes/ShipTest.class differ diff --git a/target/test-classes/SnakeTest.class b/target/test-classes/SnakeTest.class new file mode 100644 index 0000000..1c96711 Binary files /dev/null and b/target/test-classes/SnakeTest.class differ diff --git a/target/test-classes/classpath.index b/target/test-classes/classpath.index new file mode 100644 index 0000000..c12ec5a Binary files /dev/null and b/target/test-classes/classpath.index differ