diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 38bb04d..9fed8b5 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -23,6 +23,27 @@ public class Card extends JPanel { this.faceUp = faceUp; } + public boolean isFaceUp() { + return faceUp; + } + + public void setFaceUp(boolean faceUp) { + this.faceUp = faceUp; + } + + public int getNr() { + return nr; + } + + public Symbol getSymbol() { + return symbol; + } + + @Override + public String toString() { + return "Card [nr=" + nr + ", symbol=" + symbol + ", faceUp=" + faceUp + "]"; + } + - + } diff --git a/src/main/java/solitaer/CardDeck.java b/src/main/java/solitaer/CardDeck.java index 522a7fd..1387542 100644 --- a/src/main/java/solitaer/CardDeck.java +++ b/src/main/java/solitaer/CardDeck.java @@ -3,21 +3,34 @@ package solitaer; import java.util.ArrayList; public class CardDeck { - + private ArrayList deck = new ArrayList(); - - + public CardDeck() { - for(int i= 0; i<52; i++) { - deck.add(new Card(i, Symbol.Herz, false)); + for (int j = 0; j < 4; j++) { + for (int i = 0; i < 13; i++) { + switch (j) { + case 0: + deck.add(new Card(1, Symbol.Herz, false)); + break; + case 1: + deck.add(new Card(1, Symbol.Karo, false)); + break; + case 2: + deck.add(new Card(1, Symbol.Kreuz, false)); + break; + case 3: + deck.add(new Card(1, Symbol.Pik, false)); + break; + } + + } } - - } + } public ArrayList getDeck() { return deck; } - } diff --git a/src/test/java/solitaer/CardDeckTest.java b/src/test/java/solitaer/CardDeckTest.java index 751c85d..448cc87 100644 --- a/src/test/java/solitaer/CardDeckTest.java +++ b/src/test/java/solitaer/CardDeckTest.java @@ -1,21 +1,54 @@ package solitaer; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.verify; + +import java.util.stream.Stream; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class CardDeckTest { + + private CardDeck deck = new CardDeck(); @Test - void testCardDeckSize() { - CardDeck deck = new CardDeck(); - + void testCardDeckSize() { int result = deck.getDeck().size(); assertEquals(52, result, "Kartendeck muss genau 52 Carden haben") ; } + + + @ParameterizedTest + @MethodSource("testSymbole") + void testCardDeckSymbole(String msg, Symbol _sym) { + + boolean result = false; + + for(int i = 0; i testSymbole(){ + return Stream.of( + Arguments.of("Herz", Symbol.Herz), + Arguments.of("Karo", Symbol.Karo), + Arguments.of("Pik", Symbol.Pik), + Arguments.of("Kreuz",Symbol.Kreuz) + ); + + + } }