//------------------------------------------------ // ShuffledHands(CHand[] hands) // // Precondition: hands must be an array of initialized CHand objects. // Postcondition: Gives each hand 13 random cards. //------------------------------------------------ public void ShuffledHands(CHand[] hands) { bool[,] handsUsed = new bool[TotalSuits, SuitCount]; Random rand = new Random(); for(int i = 0; i < hands.Length; i++) { int cardCount = 0; while(cardCount < CHand.handSize) { int nextCardNumber = rand.Next(SuitCount); int nextCardSuit = rand.Next(TotalSuits); if (handsUsed[nextCardSuit, nextCardNumber] == false) { hands[i].Hand[cardCount].Suit = (SuitValue)nextCardSuit; hands[i].Hand[cardCount].Number = (CardValue)nextCardNumber; handsUsed[nextCardSuit, nextCardNumber] = true; cardCount++; } } } }
public CDealer() { cards = new CDeck(); players = new CHand[playerCount]; //initialize the players array. for (int i = 0; i < playerCount; i++) //create a new CHand object for all the players in the players array. players[i] = new CHand(); }
public CDealer() { cards = new CDeck(); playerHands = new CHand[playerCount]; //initialize the playerHands array. for (int i = 0; i < playerCount; i++) //create a new CHand object for all the playerHands in the playerHands array. { playerHands[i] = new CHand(); } }