Exemple #1
0
        public void Shuffle()
        {
            CardCollection newDeck = new CardCollection();

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

            for (int i = 0; i < 52; i++)
            {
                int  sourceCard = 0;
                bool foundCard  = false;
                while (foundCard == false)
                {
                    sourceCard = sourceGen.Next(52);
                    if (assigned[sourceCard] == false)
                    {
                        foundCard = true;
                    }
                }
                assigned[sourceCard] = true;
                newDeck.Add(cards[sourceCard]);
            }
            newDeck.CopyTo(cards);
        }
Exemple #2
0
 private Deck(CardCollection newCards)
 {
     cards = newCards;
 }