From 3ff0419cbf2b26616966abdea3f3e9a3d9a40bcf Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Tue, 18 Jan 2022 10:20:08 +0100 Subject: [PATCH] Add Figure.java and implement it in Player.java --- src/main/java/Figure.java | 9 +++++++++ src/main/java/Player.java | 8 ++++++++ src/test/java/PlayerTest.java | 13 +++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/main/java/Figure.java diff --git a/src/main/java/Figure.java b/src/main/java/Figure.java new file mode 100644 index 0000000..8cf72b9 --- /dev/null +++ b/src/main/java/Figure.java @@ -0,0 +1,9 @@ +public class Figure { + + int position; + + public Figure() { + this.position = -1; + } + +} diff --git a/src/main/java/Player.java b/src/main/java/Player.java index 6cba702..1a15314 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -1,9 +1,17 @@ +import javax.sound.midi.Soundbank; +import java.util.Arrays; + public class Player { String name; + Figure[] figures; public Player (String name) { this.name = name; + figures = new Figure[4]; + for(int i = 0; i < 4; i++) { + this.figures[i] = new Figure(); + } } @Override diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 86faf07..5000e0b 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -29,5 +29,18 @@ public class PlayerTest { assertThat(calculatedResult).describedAs("Player Name").isEqualTo(expectedResult); } + @Test + void checkStartPositionOfFigures() { + int expectedResult = -1; + int calculatedResult = p.figures[0].position; + for(int i = 0; i < 4; i++) { + calculatedResult = p.figures[i].position; + if(expectedResult != calculatedResult) { + calculatedResult = 1; + break; + } + } + assertThat(calculatedResult).describedAs("Starting postion of Figures").isEqualTo(expectedResult); + } }