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..e5066bc --- /dev/null +++ b/src/main/java/de/hsfulda/onses/models/Game.java @@ -0,0 +1,27 @@ +package de.hsfulda.onses.models; + +import java.util.ArrayList; + +public class Game { + private final ArrayList drawCardDeck = new ArrayList<>(); + + private Card lastPlayedCard = null; + + public Card getLastPlayedCard() { + return lastPlayedCard; + } + + public Game setLastPlayedCard(Card lastPlayedCard) { + this.lastPlayedCard = lastPlayedCard; + return this; + } + + 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 new file mode 100644 index 0000000..13bb0ff --- /dev/null +++ b/src/test/java/de/hsfulda/onses/GameTest.java @@ -0,0 +1,49 @@ +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(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); + } + + @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); + } +}