當前位置: 首頁>>代碼示例>>C#>>正文


C# Card.CompareTo方法代碼示例

本文整理匯總了C#中Card.CompareTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Card.CompareTo方法的具體用法?C# Card.CompareTo怎麽用?C# Card.CompareTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Card的用法示例。


在下文中一共展示了Card.CompareTo方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestSortCards

 public void TestSortCards()
 {
     Card testAS = new Card(1, Suit.Spades);
     Card testKS = new Card(13, Suit.Spades);
     Card testQS = new Card(12, Suit.Spades);
     List<Card> cards = new List<Card>() { testAS, testQS, testKS };
     cards.Sort();
     Assert.IsTrue(testAS.CompareTo(testKS) > 0);
     Assert.IsFalse(testKS.CompareTo(testAS) > 0);
     Assert.IsTrue(testAS.CompareTo(testQS) > 0);
     Assert.IsFalse(testQS.CompareTo(testAS) > 0);
     Assert.IsTrue(testKS.CompareTo(testQS) > 0);
     Assert.IsFalse(testQS.CompareTo(testKS) > 0);
 }
開發者ID:shahboura,項目名稱:Tarneeb,代碼行數:14,代碼來源:ShufflerTest.cs

示例2: TestCardSort

		public void TestCardSort(string first, string second, int expectedDifference)
		{
			var firstCard = new Card(first);
			var secondCard = new Card(second);

			var result = firstCard.CompareTo(secondCard);

			Assert.AreEqual(expectedDifference, result);
		}
開發者ID:droach282,項目名稱:kata-pokerhands,代碼行數:9,代碼來源:CardTests.cs

示例3: TestCardCompareJackClubsWithJackHearts

        public void TestCardCompareJackClubsWithJackHearts()
        {
            Card jackClubs = new Card(CardFace.Jack, CardSuit.Clubs);
            Card jackHearts = new Card(CardFace.Jack, CardSuit.Hearts);

            int expected = -2;
            int actual = jackClubs.CompareTo(jackHearts);
            Assert.AreEqual(expected, actual);
        }
開發者ID:nkolarov,項目名稱:telerik-academy,代碼行數:9,代碼來源:CardTests.cs

示例4: TestCardCompareAceWithJack

        public void TestCardCompareAceWithJack()
        {
            Card ace = new Card(CardFace.Ace, CardSuit.Hearts);
            Card jack = new Card(CardFace.Jack, CardSuit.Hearts);

            int expected = 3;
            int actual = ace.CompareTo(jack);
            Assert.AreEqual(expected, actual);
        }
開發者ID:nkolarov,項目名稱:telerik-academy,代碼行數:9,代碼來源:CardTests.cs

示例5: TestCardCompareAceHeartsWithAceHearts

        public void TestCardCompareAceHeartsWithAceHearts()
        {
            Card aceHearts = new Card(CardFace.Ace, CardSuit.Hearts);
            Card anotherAceHearts = new Card(CardFace.Ace, CardSuit.Hearts);

            int expected = 0;
            int actual = aceHearts.CompareTo(anotherAceHearts);
            Assert.AreEqual(expected, actual);
        }
開發者ID:nkolarov,項目名稱:telerik-academy,代碼行數:9,代碼來源:CardTests.cs

示例6: ShouldPassCompareToOffToItsIGame

        public void ShouldPassCompareToOffToItsIGame()
        {
            game.Expect(g => g.Compare(null, null)).IgnoreArguments().Return(0);

            var card1 = new Card(game) { Suit = "Clubs", Value = "5" };
            var card2 = new Card(game) { Suit = "Clubs", Value = "5" };
            card1.CompareTo(card2).ShouldBe(0);

            game.AssertWasCalled(g => g.Compare(card1, card2), mo => mo.IgnoreArguments());
        }
開發者ID:trayburn,項目名稱:GameFramework,代碼行數:10,代碼來源:CardTest.cs

示例7: CompareToTest

 public void CompareToTest()
 {
     IComparable target = new Card(); // TODO: Initialize to an appropriate value
     object obj = null; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.CompareTo(obj);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
開發者ID:Twistie,項目名稱:TwoServer,代碼行數:10,代碼來源:CardTest.cs

示例8: CompareCards

 private int CompareCards(Card card1, Card card2)
 {
     Suit tempTrump = trumpSuit;
     if (trumpSuit == Suit.None)
     {
         //Handle no trump
         trumpSuit = CurrentTrickBaseSuit;
     }
     if (card2.Suit != tempTrump && card1.Suit != tempTrump)
     {
         return 0;
     }
     else if (card2.Suit != tempTrump && card1.Suit == tempTrump)
     {
         return 1;
     }
     else if (card1.Suit != tempTrump && card2.Suit != tempTrump)
     {
         return -1;
     }
     else
     {
         return card1.CompareTo(card2);
     }
 }
開發者ID:shahboura,項目名稱:Tarneeb,代碼行數:25,代碼來源:GamePlay.cs

示例9: CompareToTest

 public void CompareToTest()
 {
     var newCard = new Card(123, 123, "Name");
     Assert.AreEqual(newCard.CompareTo(_card), 0, "CompareTo broke");
 }
開發者ID:NidentalEgor,項目名稱:CSharp,代碼行數:5,代碼來源:UnitTest.cs

示例10: TestCardComparison_LowToHigh

        public void TestCardComparison_LowToHigh()
        {
            List<Card> deck = DeckOfCards.GetPokerDeck();

            Card lowCard = new Card { rank = Rank.Deuce, suit = Suit.Diamonds };
            Card highCard = new Card { rank = Rank.Ten, suit = Suit.Clubs };

            string actual = string.Format("{0} is {1} {2}", lowCard.ToString(),
               lowCard.CompareTo(highCard) == -1 ? "lower than" : lowCard.CompareTo(highCard) == 1 ? "higher than"
               : "the same as", highCard.ToString());

            string expected = "Deuce of Diamonds is lower than Ten of Clubs";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
開發者ID:iranye,項目名稱:WorkingProjects,代碼行數:14,代碼來源:CardsUnderTest.cs

示例11: TestCardComparison_BothAreSame

        public void TestCardComparison_BothAreSame()
        {
            List<Card> deck = DeckOfCards.GetPokerDeck();

            Card highCard = new Card { rank = Rank.Ten, suit = Suit.Clubs };
            Card sameCard = new Card { rank = Rank.Ten, suit = Suit.Clubs };

            string actual = string.Format("{0} is {1} {2}", highCard.ToString(),
               highCard.CompareTo(sameCard) == -1 ? "lower than" : highCard.CompareTo(sameCard) == 1 ? "higher than"
               : "the same as", sameCard.ToString());

            string expected = "Ten of Clubs is the same as Ten of Clubs";
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
開發者ID:iranye,項目名稱:WorkingProjects,代碼行數:14,代碼來源:CardsUnderTest.cs

示例12: TestCardCompareTwoWithJack

        public void TestCardCompareTwoWithJack()
        {
            Card jack = new Card(CardFace.Jack, CardSuit.Hearts);
            Card two = new Card(CardFace.Two, CardSuit.Hearts);

            int expected = -9;
            int actual = two.CompareTo(jack);
            Assert.AreEqual(expected, actual);
        }
開發者ID:nkolarov,項目名稱:telerik-academy,代碼行數:9,代碼來源:CardTests.cs


注:本文中的Card.CompareTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。