/// <summary> /// Insert every card from a normal deck into this deck /// </summary> /// <param name="minRankIndex">The minimum rank index</param> /// <param name="maxRankIndex">The maximum rank index</param> private void InsertCards(int minRankIndex, int maxRankIndex) { for (int suitVal = 0; suitVal < 4; suitVal++) { for (int rankVal = minRankIndex; rankVal < maxRankIndex; rankVal++) { cards.Add(new PlayingCard((CardRank)rankVal, (CardSuit)suitVal)); } } }
/// <summary> /// Copies all cards in this collection to another /// </summary> /// <param name="targetCards">The target collection</param> public void CopyTo(CardCollection targetCards) { // Iterate over all my cards and clone them to the other collection for (int index = 0; index < this.Count; index++) { targetCards.Add(this[index].Clone() as PlayingCard); } }
/// <summary> /// Clones this collection /// </summary> /// <returns>A clone of this collection</returns> public object Clone() { // Create the result CardCollection newCards = new CardCollection(); // Clone each card foreach (PlayingCard sourceCard in this) { newCards.Add(sourceCard.Clone() as PlayingCard); } // Return the result return(newCards); }