当前位置: 首页>>代码示例>>C#>>正文


C# PokerHandsChecker.CompareHands方法代码示例

本文整理汇总了C#中Poker.PokerHandsChecker.CompareHands方法的典型用法代码示例。如果您正苦于以下问题:C# PokerHandsChecker.CompareHands方法的具体用法?C# PokerHandsChecker.CompareHands怎么用?C# PokerHandsChecker.CompareHands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Poker.PokerHandsChecker的用法示例。


在下文中一共展示了PokerHandsChecker.CompareHands方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompareHands_MinusOneOnSteelWheelAndHigherStraight

        public void CompareHands_MinusOneOnSteelWheelAndHigherStraight()
        {
            IList<ICard> cardsFirstHand = new List<ICard>();
            cardsFirstHand.Add(new Card(CardFace.Five, CardSuit.Clubs));
            cardsFirstHand.Add(new Card(CardFace.Ace, CardSuit.Spades));
            cardsFirstHand.Add(new Card(CardFace.Two, CardSuit.Diamonds));
            cardsFirstHand.Add(new Card(CardFace.Four, CardSuit.Spades));
            cardsFirstHand.Add(new Card(CardFace.Three, CardSuit.Hearts));

            IHand firstHand = new Hand(cardsFirstHand);

            IList<ICard> cardsSecondHand = new List<ICard>();
            cardsSecondHand.Add(new Card(CardFace.Seven, CardSuit.Diamonds));
            cardsSecondHand.Add(new Card(CardFace.Five, CardSuit.Spades));
            cardsSecondHand.Add(new Card(CardFace.Four, CardSuit.Diamonds));
            cardsSecondHand.Add(new Card(CardFace.Three, CardSuit.Clubs));
            cardsSecondHand.Add(new Card(CardFace.Six, CardSuit.Hearts));

            IHand secondHand = new Hand(cardsSecondHand);

            PokerHandsChecker checker = new PokerHandsChecker();

            int result = checker.CompareHands(firstHand, secondHand);

            Assert.AreEqual(-1, result);
        }
开发者ID:Rokata,项目名称:TelerikAcademy,代码行数:26,代码来源:PokerComparerTest.cs

示例2: CompareHands_MinusOneOnSimilarThrees

        public void CompareHands_MinusOneOnSimilarThrees()
        {
            IList<ICard> cardsFirstHand = new List<ICard>();
            cardsFirstHand.Add(new Card(CardFace.Eight, CardSuit.Clubs)); // kicker 1
            cardsFirstHand.Add(new Card(CardFace.Four, CardSuit.Spades));
            cardsFirstHand.Add(new Card(CardFace.Four, CardSuit.Diamonds));
            cardsFirstHand.Add(new Card(CardFace.Four, CardSuit.Clubs));
            cardsFirstHand.Add(new Card(CardFace.Seven, CardSuit.Diamonds)); // kicker 2

            IHand firstHand = new Hand(cardsFirstHand);

            IList<ICard> cardsSecondHand = new List<ICard>();
            cardsSecondHand.Add(new Card(CardFace.Four, CardSuit.Diamonds));
            cardsSecondHand.Add(new Card(CardFace.Four, CardSuit.Spades));
            cardsSecondHand.Add(new Card(CardFace.Nine, CardSuit.Diamonds)); // kicker 1
            cardsSecondHand.Add(new Card(CardFace.Two, CardSuit.Clubs));
            cardsSecondHand.Add(new Card(CardFace.Four, CardSuit.Clubs)); // kicker 2

            IHand secondHand = new Hand(cardsSecondHand);

            PokerHandsChecker checker = new PokerHandsChecker();

            int result = checker.CompareHands(firstHand, secondHand);

            Assert.AreEqual(-1, result);
        }
开发者ID:Rokata,项目名称:TelerikAcademy,代码行数:26,代码来源:PokerComparerTest.cs

示例3: TestCompareHandsFirstHand

 public void TestCompareHandsFirstHand()
 {
     Card cardOne = new Card(CardFace.Ace, CardSuit.Diamonds);
     Card cardTwo = new Card(CardFace.Ace, CardSuit.Hearts);
     Card cardThree = new Card(CardFace.Five, CardSuit.Spades);
     Card cardFour = new Card(CardFace.Ace, CardSuit.Clubs);
     Card cardFive = new Card(CardFace.Ace, CardSuit.Spades);
     IList<ICard> cardsOne = new List<ICard>();
     cardsOne.Add(cardOne);
     cardsOne.Add(cardTwo);
     cardsOne.Add(cardThree);
     cardsOne.Add(cardFour);
     cardsOne.Add(cardFive);
     Hand handOne = new Hand(cardsOne);
     Card cardSix = new Card(CardFace.Two, CardSuit.Diamonds);
     Card cardSeven = new Card(CardFace.Jack, CardSuit.Hearts);
     Card cardEight = new Card(CardFace.Five, CardSuit.Spades);
     Card cardNine = new Card(CardFace.Ace, CardSuit.Clubs);
     Card cardTen = new Card(CardFace.Ten, CardSuit.Clubs);
     IList<ICard> cardsTwo = new List<ICard>();
     cardsTwo.Add(cardSix);
     cardsTwo.Add(cardSeven);
     cardsTwo.Add(cardEight);
     cardsTwo.Add(cardNine);
     cardsTwo.Add(cardTen);
     Hand handTwo = new Hand(cardsTwo);
     PokerHandsChecker poker = new PokerHandsChecker();
     int result = poker.CompareHands(handOne, handTwo);
     Assert.AreEqual(1, result, "CompareHands() method in class PokerHandsChecker is not working correctly.");
 }
开发者ID:danielkaradaliev,项目名称:TelerikAcademyAssignments,代码行数:30,代码来源:CompareHandsTests.cs

示例4: Main

        static void Main()
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(new List<ICard>() 
            { 
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.King, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
            });

            IHand hand2 = new Hand(new List<ICard>() 
            { 
                new Card(CardFace.Two, CardSuit.Clubs),
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Three, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Hearts),
            });

            Console.WriteLine(hand);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine("Is valid hand: " + checker.IsValidHand(hand));
            Console.WriteLine("Is one pair: " + checker.IsOnePair(hand));
            Console.WriteLine("Is two pairs: " + checker.IsTwoPair(hand));

            Console.WriteLine(Environment.NewLine + "Compare hands. 1 for first hand. -1 for second hand. 0 for same hands");
            Console.WriteLine("Hand: {0}, Hand2: {1} Compare: {2}", hand, hand2, checker.CompareHands(hand, hand2));
        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:35,代码来源:PokerExample.cs

示例5: CompareHands_EqualFullHouses

        public void CompareHands_EqualFullHouses()
        {
            IList<ICard> firstHandCards = new List<ICard>
            {
                new Card(CardFace.Six, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Six, CardSuit.Hearts),
            };

            IList<ICard> secondHandCards = new List<ICard>
            {
                new Card(CardFace.Six, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Six, CardSuit.Hearts),
            };

            Hand firstHand = new Hand(firstHandCards);
            Hand secondHand = new Hand(secondHandCards);

            PokerHandsChecker checker = new PokerHandsChecker();

            int expected = 0;
            int actual = checker.CompareHands(firstHand, secondHand);
            Assert.AreEqual(expected, actual);
        }
开发者ID:Nottyy,项目名称:TelerikAcademy,代码行数:29,代码来源:PokerHandsCheckerTestMethodCompareHands.cs

示例6: CompareHandsTestSecondBetterThanFirst

        public void CompareHandsTestSecondBetterThanFirst()
        {
            PokerHandsChecker checker = new PokerHandsChecker();

            Hand firstHand = new Hand(new List<ICard>()
            {
                new Card(CardFace.King, CardSuit.Spades),
                new Card(CardFace.King, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Clubs),
                new Card(CardFace.Queen, CardSuit.Spades),
                new Card(CardFace.Queen, CardSuit.Clubs)
            });

            Hand secondHand = new Hand(new List<ICard>()
            {
                new Card(CardFace.Ace, CardSuit.Spades),
                new Card(CardFace.King, CardSuit.Spades),
                new Card(CardFace.Jack, CardSuit.Spades),
                new Card(CardFace.Queen, CardSuit.Spades),
                new Card(CardFace.Ten, CardSuit.Spades)
            });

            int expectedResult = 1;
            int actual;
            actual = checker.CompareHands(firstHand, secondHand);
            Assert.AreEqual(expectedResult, actual);
        }
开发者ID:bankoff,项目名称:TelerikAcademy,代码行数:27,代码来源:PokerHandsCheckerTest.cs

示例7: CompareHands_EqualFlushes

        public void CompareHands_EqualFlushes()
        {
            IList<ICard> firstHandCards = new List<ICard>
            {
                new Card(CardFace.Queen, CardSuit.Hearts),
                new Card(CardFace.Ten, CardSuit.Hearts),
                new Card(CardFace.Seven, CardSuit.Hearts),
                new Card(CardFace.Five, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Hearts),
            };

            IList<ICard> secondHandCards = new List<ICard>
            {
                new Card(CardFace.Queen, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Five, CardSuit.Clubs),
                new Card(CardFace.Three, CardSuit.Clubs),
            };

            Hand firstHand = new Hand(firstHandCards);
            Hand secondHand = new Hand(secondHandCards);

            PokerHandsChecker checker = new PokerHandsChecker();

            int expected = 0;
            int actual = checker.CompareHands(firstHand, secondHand);
            Assert.AreEqual(expected, actual);
        }
开发者ID:Nottyy,项目名称:TelerikAcademy,代码行数:29,代码来源:PokerHandsCheckerTestMethodCompareHands.cs

示例8: TestPokerCheckerCompareHighCardHandsFirstHigher

 public void TestPokerCheckerCompareHighCardHandsFirstHigher()
 {
     List<ICard> cards = new List<ICard>();
     cards.Add(new Card(CardFace.Six, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.King, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Two, CardSuit.Spades));
     cards.Add(new Card(CardFace.Jack, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Ten, CardSuit.Diamonds));
     var firstHand = new Hand(cards);
     cards = new List<ICard>();
     cards.Add(new Card(CardFace.Queen, CardSuit.Hearts));
     cards.Add(new Card(CardFace.Jack, CardSuit.Hearts));
     cards.Add(new Card(CardFace.Two, CardSuit.Clubs));
     cards.Add(new Card(CardFace.Ten, CardSuit.Hearts));
     cards.Add(new Card(CardFace.Six, CardSuit.Hearts));
     var secondHand = new Hand(cards);
     var checker = new PokerHandsChecker();
     Assert.IsTrue(checker.CompareHands(firstHand, secondHand) == 1);
 }
开发者ID:kalinalazarova1,项目名称:TelerikAcademy,代码行数:19,代码来源:PokerCheckerTest.cs

示例9: TestPokerCheckerCompareDifferentHands

 public void TestPokerCheckerCompareDifferentHands()
 {
     List<ICard> cards = new List<ICard>();
     cards.Add(new Card(CardFace.Ace, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Queen, CardSuit.Hearts));
     cards.Add(new Card(CardFace.King, CardSuit.Spades));
     cards.Add(new Card(CardFace.Eight, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Six, CardSuit.Clubs));
     var firstHand = new Hand(cards);
     cards = new List<ICard>();
     cards.Add(new Card(CardFace.Ace, CardSuit.Hearts));
     cards.Add(new Card(CardFace.Ace, CardSuit.Spades));
     cards.Add(new Card(CardFace.King, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Eight, CardSuit.Clubs));
     cards.Add(new Card(CardFace.Six, CardSuit.Hearts));
     var secondHand = new Hand(cards);
     var checker = new PokerHandsChecker();
     Assert.IsTrue(checker.CompareHands(firstHand, secondHand) == -1);
 }
开发者ID:kalinalazarova1,项目名称:TelerikAcademy,代码行数:19,代码来源:PokerCheckerTest.cs

示例10: Main

        static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(new List<ICard>() {
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.King, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
            });
            Console.WriteLine(hand);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine(checker.IsValidHand(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsTwoPair(hand));

            IList<ICard> firstCardsSet = new List<ICard>()
            {
                new Card(CardFace.Four, CardSuit.Clubs),
                new Card(CardFace.Three, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Six, CardSuit.Clubs),
                new Card(CardFace.Five, CardSuit.Diamonds)
            };

            IList<ICard> secondCardsSet = new List<ICard>()
            {
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.King, CardSuit.Spades),
                new Card(CardFace.Jack, CardSuit.Hearts),
                new Card(CardFace.Queen, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Hearts)
            };

            PokerHandsChecker handsChecker = new PokerHandsChecker();
            IHand firstHand = new Hand(firstCardsSet);
            IHand secondHand = new Hand(secondCardsSet);
            int result = handsChecker.CompareHands(firstHand, secondHand);
            Console.WriteLine(result);
        }
开发者ID:Velmond,项目名称:TelerikAcademy-CSharp,代码行数:43,代码来源:PokerExample.cs

示例11: TwoEaqualHands

        public void TwoEaqualHands()
        {
            var firstHand = new Hand(new List<ICard>() {
                new Card(CardFace.Queen, CardSuit.Hearts),
                new Card(CardFace.Seven, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Ten, CardSuit.Spades),
                new Card(CardFace.Nine, CardSuit.Clubs)
            });

            var secondHand = new Hand(new List<ICard>() {
                new Card(CardFace.Queen, CardSuit.Hearts),
                new Card(CardFace.Seven, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Ten, CardSuit.Spades),
                new Card(CardFace.Nine, CardSuit.Clubs)
            });

            var checker = new PokerHandsChecker();
            Assert.AreEqual(0, checker.CompareHands(firstHand, secondHand));
        }
开发者ID:Termininja,项目名称:TelerikAcademy,代码行数:21,代码来源:CompareHandsTests.cs

示例12: FirstHandIsPowerful

        public void FirstHandIsPowerful()
        {
            var firstHand = new Hand(new List<ICard>() {
                new Card(CardFace.Three, CardSuit.Hearts),
                new Card(CardFace.Seven, CardSuit.Hearts),
                new Card(CardFace.Five, CardSuit.Hearts),
                new Card(CardFace.Four, CardSuit.Hearts),
                new Card(CardFace.Six, CardSuit.Hearts)
            });

            var secondHand = new Hand(new List<ICard>() {
                new Card(CardFace.Queen, CardSuit.Hearts),
                new Card(CardFace.Seven, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Queen, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Clubs)
            });

            PokerHandsChecker checker = new PokerHandsChecker();
            Assert.AreEqual(1, checker.CompareHands(firstHand, secondHand));
        }
开发者ID:Termininja,项目名称:TelerikAcademy,代码行数:21,代码来源:CompareHandsTests.cs

示例13: SecondHandIsPowerful

        public void SecondHandIsPowerful()
        {
            var firstHand = new Hand(new List<ICard>() {
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Seven, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Spades),
                new Card(CardFace.Nine, CardSuit.Clubs)
            });

            var secondHand = new Hand(new List<ICard>() {
                new Card(CardFace.Jack, CardSuit.Hearts),
                new Card(CardFace.Ten, CardSuit.Spades),
                new Card(CardFace.Jack, CardSuit.Diamonds),
                new Card(CardFace.Jack, CardSuit.Spades),
                new Card(CardFace.Jack, CardSuit.Clubs)
            });

            var checker = new PokerHandsChecker();
            Assert.AreEqual(-1, checker.CompareHands(firstHand, secondHand));
        }
开发者ID:Termininja,项目名称:TelerikAcademy,代码行数:21,代码来源:CompareHandsTests.cs

示例14: EqaulHandsTest

        public void EqaulHandsTest()
        {
            IHand firstHand = new Hand(new List<ICard>() {
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Clubs),
                new Card(CardFace.Three, CardSuit.Diamonds)
            });

            IHand secondHand = new Hand(new List<ICard>() {
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Clubs),
                new Card(CardFace.Two, CardSuit.Diamonds)
            });

            PokerHandsChecker handsChecker = new PokerHandsChecker();

            Assert.IsTrue(handsChecker.CompareHands(firstHand, secondHand) == 0);
        }
开发者ID:hristo-iliev,项目名称:TelerikHW,代码行数:22,代码来源:CompareHandsTest.cs

示例15: FirstHandStrongerTest

        public void FirstHandStrongerTest()
        {
            IHand firstHand = new Hand(new List<ICard>() {
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.King, CardSuit.Clubs),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.Jack, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs)
            });

            IHand secondHand = new Hand(new List<ICard>() {
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.King, CardSuit.Clubs),
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Jack, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Clubs)
            });

            PokerHandsChecker handsChecker = new PokerHandsChecker();

            Assert.IsTrue(handsChecker.CompareHands(firstHand, secondHand) == 1);
        }
开发者ID:hristo-iliev,项目名称:TelerikHW,代码行数:22,代码来源:CompareHandsTest.cs


注:本文中的Poker.PokerHandsChecker.CompareHands方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。