diff --git a/src/main/java/inf112/fiasko/roborally/objects/Deck.java b/src/main/java/inf112/fiasko/roborally/objects/Deck.java index fc209e5..ae1e3ad 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Deck.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Deck.java @@ -3,13 +3,23 @@ package inf112.fiasko.roborally.objects; import java.util.ArrayList; import java.util.Random; +/** + * This class represents a deck of cards + */ public class Deck { private ArrayList cardDeck; + /** + * Initalizes the card deck. + * @param cardDeck a list of starting cards. + */ public Deck(ArrayList cardDeck){ this.cardDeck=cardDeck; } + /** + * This method shuffles the cards in the deck so that they are in a random order + */ public void shuffle() { Random randomNumber = new Random(); for (int i = cardDeck.size() - 1; i > 0; i--) { @@ -23,15 +33,25 @@ public class Deck { } } + + /** + * draws the first card in the card deck + * @return first card in the card deck list + */ public ProgrammingCard drawCard(){ ProgrammingCard draw = cardDeck.get(0); cardDeck.remove(0); return draw; } - + + /** + * draws n cards for another card deck and adds it to this card deck + * @param n number of cards you want to draw from the other deck + * @param otherDeck the other card deck + */ public void drawNCardsFromOtherDeck(int n, Deck otherDeck){ - if (n<1 || n>otherDeck.getCards().size()){ - throw new IllegalArgumentException("cant draw negativ cards or more cards then are in the deck"); + if (n<1 || n>otherDeck.getCard().size()){ + throw new IllegalArgumentException("cant draw negativ cards or more cards then are in the other deck"); } else{ for (int i=0;i drawAllCard(){ ArrayList allCards= new ArrayList<>(); int cardDeckSize = cardDeck.size(); @@ -56,13 +84,26 @@ public class Deck { return allCards; } - public ArrayList getCards(){ + /** + * gives a list of all the cards inn this deck + * @return a list of all the cards inn this deck + */ + public ArrayList getCard(){ return cardDeck; } + /** + * checks if this deck is empty + * @return true if empty false otherwise + */ public Boolean isEmpty(){ return cardDeck.isEmpty(); } + + /** + * gets the size of this deck + * @return size of the deck + */ public int size(){ return cardDeck.size(); }