diff --git a/src/main/java/Player.java b/src/main/java/Player.java index 57920b0..6cba702 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -1,4 +1,16 @@ public class Player { + + String name; + + public Player (String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + public int rollDice() { return (int) (Math.random() * 6); } diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 1dfa925..86faf07 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -13,7 +13,7 @@ public class PlayerTest { @BeforeEach void setup() { - p = new Player(); + p = new Player("Rot"); } @Test @@ -22,7 +22,12 @@ public class PlayerTest { assertThat(calculatedResult).describedAs("Dice result").isBetween(1,6); } - + @Test + void testToString() { + String expectedResult = "Rot"; + String calculatedResult = p.toString(); + assertThat(calculatedResult).describedAs("Player Name").isEqualTo(expectedResult); + } }