示例#1
0
文件: UnitTest1.cs 项目: djvorr/SSE
        public void TestHand()
        {
            List<Card> cards = new List<Card>();
            Card c = new Card('H', "10");
            cards.Add(c);
            Card c1 = new Card('A', "9");
            cards.Add(c1);
            Card c2 = new Card('D', "K");
            cards.Add(c2);
            Hand hand = new Hand(cards);

            //Test to make sure all cards made it into the hand.
            Assert.IsTrue(hand.getCards().Contains(c), "Hand.GetCards.Contains failed for first card.");
            Assert.IsTrue(hand.getCards().Contains(c1), "Hand.GetCards.Contains failed for second card.");
            Assert.IsTrue(hand.getCards().Contains(c2), "Hand.GetCards.Contains failed for third card.");

            //Test to make sure a removed item no longer exists, but the others still do.
            hand.removeCard(c);
            Assert.IsTrue(hand.getCards().Contains(c) == false, "Hand.GetCards.Contains failed for removed card.");
            Assert.IsTrue(hand.getCards().Contains(c1), "Hand.GetCards.Contains failed for first remaining card.");
            Assert.IsTrue(hand.getCards().Contains(c2), "Hand.GetCards.Contains failed for second remaining card.");
        }
示例#2
0
文件: Board.cs 项目: djvorr/SSE
        /// <summary>
        /// Draws the card suit and face on the respective button.
        /// </summary>
        /// <param name="h"></param>
        public void drawHand(Hand h)
        {
            List<Card> cards = h.getCards();

            //button1.Text = "derp";
            /*
            for (int i = 0; i < hand.Count; i++)
            {
                if (i < cards.Count)
                {
                    ((Button)hand[i]).Text = cards[i].getSuit() + cards[i].getFace();
                    ((Button)hand[i]).Enabled = true;
                }
                else
                {
                    ((Button)hand[i]).Text = "";
                    ((Button)hand[i]).Enabled = false;
                }
            }*/

            int i = 0;

            foreach(Control c in this.Controls)
            {
                if (c.GetType() == typeof(Button))
                {
                    if (i < h.getCards().Count)
                    {
                        if (cards[i].getFace().Length > 0)
                        {
                            ((Button)c).Text = cards[i].getSuit() + cards[i].getFace();
                            i++;
                        }
                    }
                    else
                        ((Button)c).Text = "";
                }
            }
        }