From 36cca6103cb53a62bc7866fd33045dad23fe0381 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Thu, 25 Jan 2024 12:45:13 +0100 Subject: [PATCH 1/5] Add GameModel and lastPlayedCard --- src/main/java/de/hsfulda/onses/models/Game.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/de/hsfulda/onses/models/Game.java diff --git a/src/main/java/de/hsfulda/onses/models/Game.java b/src/main/java/de/hsfulda/onses/models/Game.java new file mode 100644 index 0000000..3ac05ca --- /dev/null +++ b/src/main/java/de/hsfulda/onses/models/Game.java @@ -0,0 +1,15 @@ +package de.hsfulda.onses.models; + +public class Game { + + private Card lastPlayedCard = null; + + public Card getLastPlayedCard() { + return lastPlayedCard; + } + + public Game setLastPlayedCard(Card lastPlayedCard) { + this.lastPlayedCard = lastPlayedCard; + return this; + } +} From ef9f5a738cd49a77e459d5a68ff985e814976a41 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Thu, 25 Jan 2024 12:50:05 +0100 Subject: [PATCH 2/5] Adding drawCardDeck --- src/main/java/de/hsfulda/onses/models/Game.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/de/hsfulda/onses/models/Game.java b/src/main/java/de/hsfulda/onses/models/Game.java index 3ac05ca..be6f1e1 100644 --- a/src/main/java/de/hsfulda/onses/models/Game.java +++ b/src/main/java/de/hsfulda/onses/models/Game.java @@ -1,6 +1,9 @@ package de.hsfulda.onses.models; +import java.util.ArrayList; + public class Game { + private final ArrayList drawCardDeck = new ArrayList<>(); private Card lastPlayedCard = null; @@ -12,4 +15,8 @@ public class Game { this.lastPlayedCard = lastPlayedCard; return this; } + + public ArrayList getDrawCardDeck() { + return drawCardDeck; + } } From 4fb4c61b5382c2c57275b28b2ac7e3f396207b99 Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Thu, 25 Jan 2024 13:02:56 +0100 Subject: [PATCH 3/5] Test.lastPlayedCard --- src/test/java/de/hsfulda/onses/GameTest.java | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/java/de/hsfulda/onses/GameTest.java diff --git a/src/test/java/de/hsfulda/onses/GameTest.java b/src/test/java/de/hsfulda/onses/GameTest.java new file mode 100644 index 0000000..3ca4fd3 --- /dev/null +++ b/src/test/java/de/hsfulda/onses/GameTest.java @@ -0,0 +1,21 @@ +package de.hsfulda.onses; + +import de.hsfulda.onses.models.Card; +import de.hsfulda.onses.models.Game; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +public class GameTest { + @Test + @DisplayName("lastPlayedCard") + public void lastPlayedCard() { + Game game = new Game(); + Card card = new Card().setColor(Card.Color.RED).setValue(Card.Value.EIGHT); + Card answer = card; + + game.setLastPlayedCard(card); + + assertEquals(card, answer); + } +} From 1ee0fd37be0ac3eaafb9a5b3b7e94973ecc2f73c Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Thu, 25 Jan 2024 13:16:38 +0100 Subject: [PATCH 4/5] Test.GetDrawCardDeck --- src/main/java/de/hsfulda/onses/models/Game.java | 5 +++++ src/test/java/de/hsfulda/onses/GameTest.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hsfulda/onses/models/Game.java b/src/main/java/de/hsfulda/onses/models/Game.java index be6f1e1..e5066bc 100644 --- a/src/main/java/de/hsfulda/onses/models/Game.java +++ b/src/main/java/de/hsfulda/onses/models/Game.java @@ -19,4 +19,9 @@ public class Game { public ArrayList getDrawCardDeck() { return drawCardDeck; } + + public void addCardToDrawCardDeck(Card card) { + drawCardDeck.add(card); + } + } diff --git a/src/test/java/de/hsfulda/onses/GameTest.java b/src/test/java/de/hsfulda/onses/GameTest.java index 3ca4fd3..dc55137 100644 --- a/src/test/java/de/hsfulda/onses/GameTest.java +++ b/src/test/java/de/hsfulda/onses/GameTest.java @@ -16,6 +16,18 @@ public class GameTest { game.setLastPlayedCard(card); - assertEquals(card, answer); + assertEquals(game.getLastPlayedCard(), answer); + } + + @Test + @DisplayName("GetDrawCardDeck") + public void GetDrawCardDeck() { + Game game = new Game(); + Card card = new Card().setColor(Card.Color.RED).setValue(Card.Value.EIGHT); + Card answer = card; + + game.addCardToDrawCardDeck(card); + + assertEquals(game.getDrawCardDeck().getFirst(), answer); } } From 8762d62d8834263d2672d5ff8956589c1607ffca Mon Sep 17 00:00:00 2001 From: fdai7906 Date: Thu, 25 Jan 2024 13:22:41 +0100 Subject: [PATCH 5/5] Test.GetTwoCardsFromDrawCardDeck --- src/test/java/de/hsfulda/onses/GameTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/de/hsfulda/onses/GameTest.java b/src/test/java/de/hsfulda/onses/GameTest.java index dc55137..13bb0ff 100644 --- a/src/test/java/de/hsfulda/onses/GameTest.java +++ b/src/test/java/de/hsfulda/onses/GameTest.java @@ -30,4 +30,20 @@ public class GameTest { assertEquals(game.getDrawCardDeck().getFirst(), answer); } + + @Test + @DisplayName("GetTwoCardsFromDrawCardDeck") + public void GetTwoCardsFromDrawCardDeck() { + Game game = new Game(); + Card card1 = new Card().setColor(Card.Color.RED).setValue(Card.Value.EIGHT); + Card card2 = new Card().setColor(Card.Color.BLUE).setValue(Card.Value.ONE); + Card answer1 = card1; + Card answer2 = card2; + + game.addCardToDrawCardDeck(card1); + game.addCardToDrawCardDeck(card2); + + assertEquals(game.getDrawCardDeck().getFirst(), answer1); + assertEquals(game.getDrawCardDeck().get(1), answer2); + } }