// Method for randomizing the order of cards in the Deck object
        public void Shuffle()
        {
            Cards newDeck = new Cards();

            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);
        }
        public void Shuffle()
        {
            //Card[] newDeck = new Card[52];
            Cards newDeck = new Cards();

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

            for (int i = 0; i < 52; ++i)
            {
                //int destCard = 0;
                int  sourceCard = 0;
                bool foundCard  = false;
                while (foundCard == false)
                {
                    //destCard = sourceGen.Next(52);
                    sourceCard = sourceGen.Next(52);
                    //if (assigned[destCard] == false)
                    if (assigned[sourceCard] == false)
                    {
                        foundCard = true;
                    }
                }
                assigned[sourceCard] = true;
                //newDeck[destCard] = cards[i];
                newDeck.Add(cards[sourceCard]);
            }
            newDeck.CopyTo(cards);
        }
Beispiel #3
0
        public void Shuffle()
        {
            //Card[] newDeck = new Card[CardsNum];
            Cards newDeck = new Cards();

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

            for (int i = 0; i < CardsNum; i++)
            {
                int  deskCard  = 0;
                bool foundCard = false;
                while (foundCard == false)
                {
                    deskCard = sourceGen.Next(CardsNum);
                    if (assigned[deskCard] == false)
                    {
                        foundCard = true;
                    }
                }
                assigned[deskCard] = true;
                //newDeck[deskCard] = cards[i];
                newDeck.Add(cards[deskCard]);
            }
            newDeck.CopyTo(cards);
        }
Beispiel #4
0
        //shuffle method, randomizes the order of the cards,
        //then uses the copy to method in cardlist to copy over the cards to a new deck.
        public void Shuffle(int deckSize)
        {
            Cards newDeck = new Cards();

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

            for (int i = 0; i < deckSize; i++)
            {
                int  sourceCard = 0;
                bool foundCard  = false;
                while (foundCard == false)
                {
                    sourceCard = sourceGen.Next(deckSize);
                    if (assigned[sourceCard] == false)
                    {
                        foundCard = true;
                    }
                }
                assigned[sourceCard] = true;
                newDeck.Add(theBoard[sourceCard]);
            }
            newDeck.CopyTo(theBoard);
        }
Beispiel #5
0
 public void Shuffle()
 {
     Cards newDeck = new Cards();
       bool[] assigned = new bool[cards.Count ];
       Random sourceGen = new Random();
       for (int i = 0; i < cards.Count ; i++)
       {
     int sourceCard = 0;
     bool foundCard = false;
     while (foundCard == false)
     {
       sourceCard = sourceGen.Next(cards.Count );
       if (assigned[sourceCard] == false)
     foundCard = true;
     }
     assigned[sourceCard] = true;
     newDeck.Add(cards[sourceCard]);
       }
       newDeck.CopyTo(cards);
 }
Beispiel #6
0
 //Shuffle cards in deck
 public void Shuffle()
 {
     Cards tempDeck = new Cards();
     Random position = new Random();
     bool[] isSelect = new bool[52];
     for (int countPos = 0; countPos <= 51; countPos++)
     {
         bool isAssigned = false;
         do
         {
             int posCard = position.Next(52);
             if (isSelect[posCard])
                 continue;
             else
             {
                 isSelect[posCard] = true;
                 isAssigned = true;
                 tempDeck.Add(this.deck[posCard]);
             }
             tempDeck.CopyTo(this.deck);
         } while (!isAssigned);
     }
 }
 public void Shuffle()
 {
     Random rnd = new Random();
     Cards newDeck = new Cards();
     bool[] assigned = new bool[52];
     for (int i = 0; i < 52; i++)
     {
         int sourceCard = 0;
         bool foundCard = false;
         while (foundCard == false)
         {
             sourceCard = rnd.Next(52);
             if (assigned[sourceCard] == false)
                 foundCard = true;
         }
         assigned[sourceCard] = true;
         newDeck.Add(cards[sourceCard]);
     }
     newDeck.CopyTo(cards);
 }