Exemplo n.º 1
0
 public void Shuffle() {
     currDeckCount = 0;
     rand = new RandomGen();
     spadeCards = new Spade();
     diamondCards = new Diamond();
     heartCards = new Heart();
     clubCards = new Club();
 }
Exemplo n.º 2
0
        /// <summary>
        /// returns a spade card
        /// </summary>
        /// <returns></returns>
        public string GetCard() {
            int cardnumber = 0;
            RandomGen rand = new RandomGen();

            //check if there are any cards on deck
            if (clubCards.Count >= MaxCardCount)
                return string.Empty;
 
            //check if new card exists, if exists create new one
            while (cardnumber==0) {
                //generate a random number each time                 
                cardnumber = rand.Next(MaxCardCount); 
                if (!clubCards.Contains(cardnumber)) {//card not found/new card
                    clubCards.Add(cardnumber);
                    break;
                } else {
                    cardnumber = 0;//card exists
                }
            }
            return "CLUB " + cardnumber;
        }