Browse Source

Merge branch 'addPlayerModel' into 'main'

Add player model

See merge request fdai7736/onses!10
main
fdai7793 11 months ago
parent
commit
ce892d1d87
  1. 16
      src/main/java/de/hsfulda/onses/models/Player.java
  2. 46
      src/test/java/de/hsfulda/onses/PlayerTest.java

16
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<Card> playerDeck = new ArrayList<>();
public ArrayList<Card> getPlayerDeck() {
return playerDeck;
}
public void addCardToPlayerDeck(Card card) {
playerDeck.add(card);
}
}

46
src/test/java/de/hsfulda/onses/PlayerTest.java

@ -0,0 +1,46 @@
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);
}
@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);
}
}
Loading…
Cancel
Save