static void Main(string[] args) { Deck deck = new Deck(); for (int i = 0; i <= 3; i++) { string suit = ""; if (i == 0) suit = "hearts"; else if (i == 1) suit = "diamonds"; else if (i == 2) suit = "clubs"; else if (i == 3) suit = "spades"; for (int j = 2; j <= 14; j++) { Card card = new Card { Suit = suit, Number = j }; deck.AddCard(card); } } deck.PrintDeck(); deck.Shuffle(); deck.Shuffle(); deck.Shuffle(); deck.PrintDeck(); }
public void Remove(Card cardToFind) { if (m_cards.Contains(cardToFind)) { m_cards.Remove(cardToFind); } }
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 Test_Constructor_SetsAFaceOnTheCard_WhenGivenAFace() { //Arrange testFace = Face.Jack; //Act testCard = new Card(Suit.Hearts, testFace, false); //Assert Assert.AreEqual(testFace, testCard.face); }
public void Test_SetCardValue_SetsAValueOnTheCard_WhenGivenANumberFace() { //Arrange testFace = Face.Eight; expectedValue = 8; //Act Card testCard = new Card(Suit.Diamonds, testFace, false); //Assert Assert.AreEqual(expectedValue, testCard.value); }
public void Test_Constructor_CallsSetCardValueOnce_WhenGivenAFaceAndSuit() { //Arrange Mock<Card> mockCard = new Mock<Card>(Suit.Hearts, Face.King, false); // mockCard.Setup(x => x.SetCardValue(It.IsAny<Face>())); //Act testCard = mockCard.Object; //Assert mockCard.Verify(x => x.SetCardValue(It.IsAny<Face>(), It.IsAny<bool>()), Times.Once); }
/// <summary> /// Simple method to grab cards for a standard 52 deck. /// /// A neat way to store this would be to add to a configuration/XML file and read /// the cards that way. For this example, we'll stick with generating the cards with code. /// </summary> /// <returns></returns> private static List<Card> GetCardsForStandardDeck() { const int minValue = 1; const int maxValue = 13; var suits = GetSuitsForStandardDeck(); var cards = new List<Card>(); // create 13 cards for each suit // in this case we have four suits in a standard deck foreach (Suit suit in suits) { for (int value = minValue; value <= maxValue; value++) { var card = new Card(suit, value, GetNameForCard(value)); cards.Add(card); } } return cards; }
public void AddCard(Card card) { deck.Add(card); }
public void RemoveCard(Card card) { _cards.Remove(card); }
public bool Contains(Card cardToFind) { return m_cards.Contains(cardToFind); }
public void Add(Card newCard) { m_cards.Add(newCard); }
public Hand(Card[] cards) { m_cards.AddRange(cards); }
public void Test_SetCardValue_SetsTheValueToTen_WhenGivenAKingCard() { //Arrange testCard = new Card(Suit.Hearts, Face.King, false); testFace = Face.King; expectedValue = 10; //Act actualValue = testCard.SetCardValue(testFace, false); //Assert Assert.AreEqual(expectedValue, actualValue); }
public void Test_SetCardValue_SetsValueOfToEleven_WhenGivenAnAceAndAcesAreHigh() { //Arrange testCard = new Card(Suit.Spades, Face.Ace, false); testFace = Face.Ace; bool acesAreHigh = true; expectedValue = 11; //Act actualValue = testCard.SetCardValue(testFace, acesAreHigh); //Assert Assert.AreEqual(expectedValue, actualValue); }
public static string GetCardName(Card card) { return (GetCardValue(card.cardvalue) + " of " + GetCardSuit(card.cardsuit)); }
public static bool AreCardsEqual(Card card1, Card card2) { return (card1.cardsuit == card2.cardsuit && card1.cardvalue == card2.cardvalue); }