From d1ee446cc4c819d5311e538b794c73145020738f Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Wed, 9 Feb 2022 11:49:52 +0100 Subject: [PATCH] Refactor Player toString --- src/main/java/Game.java | 4 ++-- src/main/java/Player.java | 5 ----- src/test/java/PlayerTest.java | 7 ------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 1bccc63..504800c 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -15,7 +15,7 @@ public class Game { for (Player p : g.players) { int c = 0; int dice; - System.out.println("Spieler " + p.toString() + " an der Reihe."); + System.out.println("Spieler " + p.name + " an der Reihe."); do { int figId; dice = p.rollDice(); @@ -32,7 +32,7 @@ public class Game { } while (g.checkDice(dice, p, c)); if(p.checkGameWin(p.figures)) { winner = p; - System.out.println("Spieler " + winner.toString() + " gewinnt!"); + System.out.println("Spieler " + winner.name + " gewinnt!"); exit(42); } } diff --git a/src/main/java/Player.java b/src/main/java/Player.java index 2180cb4..fd04ee1 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -20,11 +20,6 @@ public class Player { } } - @Override - public String toString() { - return name; - } - public int rollDice() { return (int) (Math.random() * 6 + 1); } diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 93a2c43..0a38a78 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -25,13 +25,6 @@ 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); - } - @Test void checkStartPositionOfFigures() { int expectedResult = -1;