Exemple #1
0
 public void add(Card card)
 {
     if (cards.Contains(card)) {
         throw new DeckIntegrityException("Cannot contain the same card twice!");
     } else {
         cards.Add(card);
     }
 }
        private bool canAddCardTo(List<Card> cards, Card Card)
        {
            var numCards = cards.Count;

            if (numCards > 0) {
                var PreviousCard = cards[cards.Count - 1];

                if (PreviousCard.isAce() && Card.getFaceValue() == 5) {
                    return true;
                } else if (PreviousCard.getFaceValue() - 1 == Card.getFaceValue()) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return true;
            }
        }