/// <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]; } }
/// <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); }
/// <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); }
/// <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; }
/// <summary> /// Equals implementation (Required for IEquatable) /// </summary> /// <param name="obj">PlayingCards</param> /// <returns>bool</returns> public bool Equals(PlayingCards obj) { return(this == (PlayingCards)obj); }