Beispiel #1
0
 public Deck()
 {
     cards = new Card[52];
     for (int suitVal = 0; suitVal < 4; suitVal++)
     {
         for (int rankVal = 1; rankVal < 14; rankVal++)
         {
             cards[suitVal*13 + rankVal - 1] = new Card((Suit) suitVal, (Rank) rankVal);
         }
     }
 }
Beispiel #2
0
 public void Shuffle()
 {
     Card[] newDeck = new Card[52];
     bool[] assigned = new bool[52];
     Random sourceGen = new Random();
     for (int i = 0; i < 52;i++ )
     {
         int destCard = 0;
         bool foundCard = false;
         while(foundCard==false)
         {
             destCard = sourceGen.Next(52);
             if (assigned[destCard] == false)
                 foundCard = true;
         }
         assigned[destCard] = true;
         newDeck[destCard] = cards[i];
     }
     newDeck.CopyTo(cards,0);
 }