From 3dea3b19485483d00037c873488db459f0b3871f Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Tue, 21 Dec 2021 14:39:47 +0100 Subject: [PATCH] gameexplorer: addPoints() increases / decreases points of player --- src/main/java/de/tims/gameexplorer/Player.java | 2 +- src/test/java/de/tims/gameexplorer/PlayerTest.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/tims/gameexplorer/Player.java b/src/main/java/de/tims/gameexplorer/Player.java index 34ede76..4bae8ab 100644 --- a/src/main/java/de/tims/gameexplorer/Player.java +++ b/src/main/java/de/tims/gameexplorer/Player.java @@ -9,7 +9,7 @@ public class Player { } public void addPoints(int pointsToAdd) { - this.points = pointsToAdd; + this.points += pointsToAdd; } public int getPoints() { diff --git a/src/test/java/de/tims/gameexplorer/PlayerTest.java b/src/test/java/de/tims/gameexplorer/PlayerTest.java index 2711727..716245b 100644 --- a/src/test/java/de/tims/gameexplorer/PlayerTest.java +++ b/src/test/java/de/tims/gameexplorer/PlayerTest.java @@ -23,7 +23,9 @@ class PlayerTest { private static Stream testCasesForAddPoints() { return Stream.of(Arguments.of("NoPointsBeforeGet0Points", 0, 0, 0), - Arguments.of("NoPointsBeforeGet10Points", 0, 10, 10)); + Arguments.of("NoPointsBeforeGet10Points", 0, 10, 10), + Arguments.of("10PointsBeforeAdd10Points", 10, 10, 20), + Arguments.of("10PointsBeforeLose10Points", 10, -10, 0)); } }