public Card(Suit suit, Face face, bool acesAreHigh) { this.suit = suit; this.face = face; this.acesAreHigh = acesAreHigh; this.value = SetCardValue(face, acesAreHigh); }
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])); } } }
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); }
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; } } }
/// <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(); }
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; }
public Deck(Suit[] suits, FaceValue[] values) { this.MakeDeck(suits, values); }
public Card(Suit newSuit, FaceValue newValue) { m_suit = newSuit; m_faceValue = newValue; }
public Card(Rank r, Suit s) { this.Rank = r; this.Suit = s; }
//STEP 2. Constructors public Cards(Rank rank, Suit suit) { //initialize the properties this.Rank = rank; this.Suit = suit; }