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


C# Poker.PokerHandsChecker类代码示例

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


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

示例1: 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

示例2: Main

        public static void Main()
        {
            XmlConfigurator.Configure();
            Log.Info("Info logging");
            try
            {
                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.Jack, CardSuit.Diamonds),
                    new Card(CardFace.King, CardSuit.Hearts),
                    new Card(CardFace.Ten, CardSuit.Spades),
                    new Card(CardFace.Queen, CardSuit.Diamonds),
                });

                Console.WriteLine(hand);
                IPokerHandsChecker checker = new PokerHandsChecker();
                Console.WriteLine("Valid hand? : {0}", checker.IsValidHand(hand));
                Console.WriteLine("Is Straight : {0}", checker.IsStraight(hand));
                Console.WriteLine("Is one pair : {0}", checker.IsOnePair(hand));
                Console.WriteLine("Is two pair : {0}", checker.IsTwoPair(hand));
            }
            catch (Exception e)
            {
                Log.Error("This is my error", e);
            }
        }
开发者ID:AleksNiklev,项目名称:Poker-Game,代码行数:29,代码来源:PokerExample.cs

示例3: TestIsValid2

        public void TestIsValid2()
        {
            IPokerHandsChecker checker = new PokerHandsChecker();
            bool validHand = checker.IsValidHand(null);

            Assert.AreEqual(false, validHand, "Hand validation was not successful.");
        }
开发者ID:niki-funky,项目名称:Telerik_Academy,代码行数:7,代码来源:PokerHandsCheckerTest.cs

示例4: CompareHandsTestFirstBetterThanSecond

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

            Hand firstHand = 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)
            });

            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.Ten, 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

示例5: 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.IsStraight(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsTwoPair(hand));
            Console.WriteLine(checker.IsStraightFlush(hand));
            Console.WriteLine(checker.IsFlush(hand));
            Console.WriteLine(checker.IsFourOfAKind(hand));
            Console.WriteLine(checker.IsThreeOfAKind(hand));
            Console.WriteLine(checker.IsHighCard(hand));
            Console.WriteLine(checker.IsFullHouse(hand));
        }
开发者ID:vladislav-karamfilov,项目名称:TelerikAcademy,代码行数:26,代码来源:PokerExample.cs

示例6: 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

示例7: HighCardTrueTest

        public void HighCardTrueTest()
        {
            var card1 = new Card(CardFace.King, CardSuit.Hearts);
            var card2 = new Card(CardFace.Five, CardSuit.Spades);
            var card3 = new Card(CardFace.Seven, CardSuit.Diamonds);
            var card4 = new Card(CardFace.Ten, CardSuit.Clubs);
            var card5 = new Card(CardFace.Two, CardSuit.Spades);

            var cards = new List<ICard>();
            cards.Add(card1);
            cards.Add(card2);
            cards.Add(card3);
            cards.Add(card4);
            cards.Add(card5);

            // ♣
            // ♦
            // ♥
            // ♠

            Hand hand = new Hand(cards);

            bool expected = true;
            PokerHandsChecker checker = new PokerHandsChecker();
            bool actual = checker.IsHighCard(hand);
            Assert.AreEqual(expected, actual);
        }
开发者ID:abaditsegay,项目名称:SVN,代码行数:27,代码来源:PokerHandsTests.cs

示例8: 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));

            var card1 = new Card(CardFace.Jack, CardSuit.Clubs);
            var card2 = new Card(CardFace.Nine, CardSuit.Diamonds);
            var card3 = new Card(CardFace.Four, CardSuit.Spades);
            var card4 = new Card(CardFace.Two, CardSuit.Hearts);
            var card5 = new Card(CardFace.Queen, CardSuit.Hearts);

            var hand2 = new Hand(new List<ICard> { card1, card2, card3, card4, card5 });
            Console.WriteLine(hand2);
        }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:28,代码来源:PokerExample.cs

示例9: 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

示例10: Main

        internal 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.IsTwoPairs(hand));

            int a = 5;
            int b = 6;

            Console.WriteLine(b.CompareTo(a));
        }
开发者ID:Nottyy,项目名称:TelerikAcademy,代码行数:25,代码来源:PokerExample.cs

示例11: 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

示例12: 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

示例13: 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

示例14: TestIsFlushFiveDifferentFaceEaqualSuitsNotSerial

        public void TestIsFlushFiveDifferentFaceEaqualSuitsNotSerial()
        {
            IList<ICard> cards = new List<ICard>();

            Card card1 = new Card(CardFace.Ace, CardSuit.Spades);
            cards.Add(card1);

            Card card2 = new Card(CardFace.Ten, CardSuit.Spades);
            cards.Add(card2);

            Card card3 = new Card(CardFace.Queen, CardSuit.Spades);
            cards.Add(card3);

            Card card4 = new Card(CardFace.Jack, CardSuit.Spades);
            cards.Add(card4);

            Card card5 = new Card(CardFace.Seven, CardSuit.Spades);
            cards.Add(card5);

            Hand hand = new Hand(cards);
            PokerHandsChecker checker = new PokerHandsChecker();

            bool actual = checker.IsFlush(hand);
            bool expected = true;

            Assert.AreEqual(expected, actual);
        }
开发者ID:ValMomchilova,项目名称:TelerikAcademyHomeWorks,代码行数:27,代码来源:HandTests.cs

示例15: CompareHandsTestSecondEqualToFirst

        public void CompareHandsTestSecondEqualToFirst()
        {
            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.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)
            });

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


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