From 61fbdc5650b683282986eec6f567d3da3bd37e39 Mon Sep 17 00:00:00 2001 From: fdai7793 Date: Wed, 24 Jan 2024 15:11:21 +0100 Subject: [PATCH 1/3] addPlayerDeck --- .../java/de/hsfulda/onses/models/Player.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/de/hsfulda/onses/models/Player.java diff --git a/src/main/java/de/hsfulda/onses/models/Player.java b/src/main/java/de/hsfulda/onses/models/Player.java new file mode 100644 index 0000000..77eb2b1 --- /dev/null +++ b/src/main/java/de/hsfulda/onses/models/Player.java @@ -0,0 +1,16 @@ +package de.hsfulda.onses.models; + +import java.util.ArrayList; + +public class Player { + + private final ArrayList playerDeck = new ArrayList<>(); + + public ArrayList getPlayerDeck() { + return playerDeck; + } + + public void addCardToPlayerDeck(Card card) { + playerDeck.add(card); + } +} From 1bc487eab713c786bdf8beb805dd8418de854fda Mon Sep 17 00:00:00 2001 From: fdai7793 Date: Wed, 24 Jan 2024 15:13:29 +0100 Subject: [PATCH 2/3] test_AddCardToPlayerDeck --- .../java/de/hsfulda/onses/PlayerTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/java/de/hsfulda/onses/PlayerTest.java diff --git a/src/test/java/de/hsfulda/onses/PlayerTest.java b/src/test/java/de/hsfulda/onses/PlayerTest.java new file mode 100644 index 0000000..010b5a3 --- /dev/null +++ b/src/test/java/de/hsfulda/onses/PlayerTest.java @@ -0,0 +1,28 @@ + +package de.hsfulda.onses; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +import de.hsfulda.onses.models.Card; +import de.hsfulda.onses.models.Player; + +import java.util.ArrayList; + +public class PlayerTest { + + @Test + @DisplayName("AddCardToPlayerDeck") + public void AddCardToPlayerDeck() { + + // arrange + Player player = new Player(); + Card testCard = new Card().setColor(Card.Color.BLACK).setValue(Card.Value.FIVE); + // act + player.addCardToPlayerDeck(testCard); + Card firstCardPlayerDeck = player.getPlayerDeck().getFirst(); + // assert + assertEquals(testCard, firstCardPlayerDeck); + } +} From 954a1d75c55f96838bf380208909cf25b82634d4 Mon Sep 17 00:00:00 2001 From: fdai7793 Date: Wed, 24 Jan 2024 15:16:22 +0100 Subject: [PATCH 3/3] test_AddMultipleCardsToPlayerDeck --- src/test/java/de/hsfulda/onses/PlayerTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/de/hsfulda/onses/PlayerTest.java b/src/test/java/de/hsfulda/onses/PlayerTest.java index 010b5a3..80c68d5 100644 --- a/src/test/java/de/hsfulda/onses/PlayerTest.java +++ b/src/test/java/de/hsfulda/onses/PlayerTest.java @@ -25,4 +25,22 @@ public class PlayerTest { // assert assertEquals(testCard, firstCardPlayerDeck); } + + @Test + @DisplayName("AddMultipleCardsToPlayerDeck") + public void AddMultipleCardsToPlayerDeck() { + + // arrange + Player player = new Player(); + Card testCard1 = new Card().setColor(Card.Color.BLACK).setValue(Card.Value.FIVE); + Card testCard2 = new Card().setColor(Card.Color.YELLOW).setValue(Card.Value.FIVE); + // act + player.addCardToPlayerDeck(testCard1); + player.addCardToPlayerDeck(testCard2); + Card firstCardPlayerDeck = player.getPlayerDeck().getFirst(); + Card secondCardPlayerDeck = player.getPlayerDeck().get(1); + // assert + assertEquals(testCard1, firstCardPlayerDeck); + assertEquals(testCard2, secondCardPlayerDeck); + } }