Ejemplo n.º 1
0
 /// <summary>
 /// Required ICollectionBase method
 /// </summary>
 /// <param name="cards">PlayingCards</param>
 public void CopyTo(PlayingCards cards)
 {
     for (int i = 0; i < this.Count; i++)
     {
         cards[i] = this[i];
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Function: getSameLength
        /// Determines if two groups of cards have the same number of cards in them
        /// </summary>
        /// <param name="leftCards">PlayingCards</param>
        /// <param name="rightCards">PlayingCards</param>
        /// <returns>bool</returns>
        public static bool getSameLength(PlayingCards leftCards, PlayingCards rightCards)
        {
            bool bRet          = false;
            int  cntLeftCards  = leftCards.Count;
            int  cntRightCards = rightCards.Count;

            if (!(cntLeftCards < cntRightCards))
            {
                if (!(cntRightCards < cntLeftCards))
                {
                    bRet = true;
                }
            }
            return(bRet);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// counts each card in each collection and evaluates how many cards in first parameter are
        /// greater thans cards in the second parameter
        /// </summary>
        /// <param name="firstCards">PlayingCards</param>
        /// <param name="secondCards">PlayingCards</param>
        /// <returns>int</returns>
        private static int getGreaterThans(PlayingCards firstCards, PlayingCards secondCards)
        {
            int greaterThans   = 0;
            int cntFirstCards  = firstCards.Count;
            int cntSecondCards = secondCards.Count;

            //offset cnt because .Count att. is 1-based
            for (int secondCounter = cntSecondCards - 1; secondCounter >= 0; secondCounter--)
            {
                for (int firstCounter = cntFirstCards - 1; firstCounter >= 0; firstCounter--)
                {
                    if (firstCards[firstCounter] > secondCards[secondCounter])
                    {
                        greaterThans++;
                    }
                }
            }
            return(greaterThans);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// counts each card in each collection and evaluates how many cards are equals in both collections
        /// </summary>
        /// <param name="firstCards">PlayingCards</param>
        /// <param name="secondCards">PlayingCards</param>
        /// <returns>int</returns>
        private static int getEqualsTos(PlayingCards firstCards, PlayingCards secondCards)
        {
            int equalsTos      = 0;
            int cntFirstCards  = firstCards.Count;
            int cntSecondCards = secondCards.Count;

            //offset cnt because .Count att. is 1-based
            for (int secondCounter = cntSecondCards - 1; secondCounter >= 0; secondCounter--)
            {
                for (int firstCounter = cntFirstCards - 1; firstCounter >= 0; firstCounter--)
                {
                    if (firstCards[firstCounter] == secondCards[secondCounter])
                    {
                        equalsTos++;
                    }
                }
            }
            return(equalsTos);
        }
 public CardAlreadyInDeckException(PlayingCards srcDeckContents)
     : base("The card is already in the deck.")
 {
     deckContents = srcDeckContents;
 }
 public CardOutOfRangeException(PlayingCards srcDeckContents)
     : base("There are only 52 cards in the deck.")
 {
     deckContents = srcDeckContents;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Equals implementation (Required for IEquatable)
 /// </summary>
 /// <param name="obj">PlayingCards</param>
 /// <returns>bool</returns>
 public bool Equals(PlayingCards obj)
 {
     return(this == (PlayingCards)obj);
 }