Exemple #1
0
 public Card(Suit suit, Face face, bool acesAreHigh)
 {
     this.suit = suit;
     this.face = face;
     this.acesAreHigh = acesAreHigh;
     this.value = SetCardValue(face, acesAreHigh);
 }
Exemple #2
0
 private void MakeDeck(Suit[] suits, FaceValue[] values)
 {
     for (int aSuit = 0; aSuit < suits.Length; aSuit++)
     {
         for (int avalue = 0; avalue < values.Length; avalue++)
         {
             m_cards.Add(new Card(suits[aSuit], values[avalue]));
         }
     }
 }
Exemple #3
0
        public void Test_Constructor_SetsASuitOnTheCard_WhenGivenASuit()
        {
            //Arrange
            testSuit = Suit.Diamonds;

            //Act
            testCard = new Card(testSuit, Face.Ace , false);

            //Assert
            Assert.AreEqual(Suit.Diamonds, testCard.suit);
        }
Exemple #4
0
 public void Remove(Suit suitToFind, FaceValue valueToFind)
 {
     Card aCard;
     for (int i = 0; i < m_cards.Count; i++)
     {
         aCard = (Card)m_cards[i];
         if ((aCard.Suit == suitToFind) && (aCard.FaceValue == valueToFind))
         {
             m_cards.Remove(aCard);
             break;
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// Create a new card.
        /// </summary>
        /// <param name="suit">The <see cref="Suit"/> of the card to create.</param>
        /// <param name="value">The face value of the card between 1-13.</param>
        /// <param name="name">An optional name for the card, i.e: Queen, King, Ace</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public Card(Suit suit, int value, string name = "")
        {
            if (suit == null)
            {
                throw new ArgumentNullException(nameof(suit), "The suit cannot be null.");
            }

            Suit = suit;
            Value = value;

            // if a name was provided we'll go ahead and assign it
            // otherwise the name will be whatever the value provided
            Name = !String.IsNullOrWhiteSpace(name) ? name : value.ToString();
        }
Exemple #6
0
 public bool Contains(Suit suitToFind, FaceValue valueToFind)
 {
     bool found = false;
     Card aCard;
     for (int i = 0; i < m_cards.Count; i++)
     {
         aCard = (Card)m_cards[i];
         if ((aCard.Suit == suitToFind) && (aCard.FaceValue == valueToFind))
         {
             found = true;
         }
     }
     return found;
 }
Exemple #7
0
 public Deck(Suit[] suits, FaceValue[] values)
 {
     this.MakeDeck(suits, values);
 }
Exemple #8
0
 public Card(Suit newSuit, FaceValue newValue)
 {
     m_suit = newSuit;
     m_faceValue = newValue;
 }
Exemple #9
0
 public Card(Rank r, Suit s)
 {
     this.Rank = r;
     this.Suit = s;
 }
Exemple #10
0
 //STEP 2. Constructors
 public Cards(Rank rank, Suit suit)
 {
     //initialize the properties
     this.Rank = rank;
     this.Suit = suit;
 }