Пример #1
0
        public void Shuffle()
        {
            Cards newCards = new Cards();

            bool[] assigned   = new bool[52];
            Random itemRandom = new Random();

            for (int i = 0; i < 52; i++)
            {
                int  foundCard = 1;
                bool founded   = false;
                while (!founded)
                {
                    foundCard = itemRandom.Next(52);
                    if (!assigned[foundCard])
                    {
                        founded = true;
                    }
                }
                newCards.AddCard(_cards[foundCard]);
                assigned[foundCard] = true;
            }

            newCards.CopyTo(_cards, 0);
        }
Пример #2
0
 public Deck()
 {
     _cards = new Cards();
     for (int suitVal = 0; suitVal < 4; suitVal++)
     {
         for (int rankVal = 1; rankVal < 14; rankVal++)
         {
             _cards.AddCard(new Card((Suit)suitVal, (Rank)rankVal));
         }
     }
 }