Beispiel #1
0
 protected void Shuffle(ICardSuit suit)
 {
     for (var i = suit.Cards.Count - 1; i > 0; i--)
     {
         var temp  = suit.Cards[i];
         var index = random.Next(0, i + 1);
         suit.Cards[i]     = suit.Cards[index];
         suit.Cards[index] = temp;
     }
 }
Beispiel #2
0
        public Card(ICardName name, ICardSuit suit)
        {
            if (name == null)
            {
                throw new ArgumentException("Card name cannot be null");
            }

            if (suit == null)
            {
                throw new ArgumentException("Card suit cannot be null");
            }

            this.Name = name;
            this.Rank = new CardRank(this.Name);
            this.Suit = suit;
        }
        public void Print(ICardSuit deck)
        {
            if (deck == null)
            {
                throw new NullReferenceException("The deck informed to print is null.");
            }

            if (deck.Cards == null)
            {
                throw new NullReferenceException("No cards available to print.");
            }

            foreach (var card in deck.Cards)
            {
                Console.WriteLine($"{card.CardValue} of {card.Type}");
            }

            Console.WriteLine();
        }
Beispiel #4
0
 public Card(ICardSuit suit, ICardValue value)
 {
     _suit  = suit;
     _value = value;
 }
Beispiel #5
0
 public void Print(ICardSuit cardSuit)
 {
     // do nothing...
 }