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


C# PokerHandsChecker.IsValidHand方法代碼示例

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


在下文中一共展示了PokerHandsChecker.IsValidHand方法的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: Main

        private static void Main()
        {
            try
            {
                IHand hand = new Hand(new List<ICard>() 
                { 
                    new Card(CardFace.Ace, CardSuit.Clubs),
                    new Card(CardFace.Queen, CardSuit.Clubs),
                    new Card(CardFace.King, CardSuit.Clubs),
                    new Card(CardFace.Jack, CardSuit.Clubs),
                    new Card(CardFace.Ten, CardSuit.Clubs),
                });
                Console.WriteLine(hand);
                IPokerHandsChecker checker = new PokerHandsChecker();

                Console.WriteLine(checker.IsValidHand(hand) ? "Hand is valid." : "Hand is not valid!");
                Console.WriteLine(checker.IsRoyalFlush(hand) ? "Royal flush." : "Hand is not Royal flush!");
                Console.WriteLine(checker.IsStraightFlush(hand) ? "Straight flush." : "Hand is not Straight flush!");
                Console.WriteLine(checker.IsFlush(hand) ? "Flush." : "Hand is not Flush!");
                Console.WriteLine(checker.IsStraight(hand) ? "Straight." : "Hand is not Straight!");
                Console.WriteLine(checker.IsFullHouse(hand) ? "Full house." : "Hand is not Full house!");
                Console.WriteLine(checker.IsFourOfAKind(hand) ? "Four of a kind." : "Hand is not Four of a kind!");
                Console.WriteLine(checker.IsThreeOfAKind(hand) ? "Three of a kind." : "Hand is not Three of a kind!");

                IHand hand1 = new Hand("K♥ J♥ 8♣ 7♦ 4♠");
                Console.WriteLine(hand1);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
開發者ID:niki-funky,項目名稱:Telerik_Academy,代碼行數:32,代碼來源:PokerDemo.cs

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

示例5: IsFourOfAKind

        public bool IsFourOfAKind(IHand hand)
        {
            PokerHandsChecker checker = new PokerHandsChecker();
            if (!checker.IsValidHand(hand))
            {
                return false;
            }

            int counter = 0;
            for (int i = 0; i < hand.Cards.Count; i++)
            {
                for (int j = 0; j < hand.Cards.Count; j++)
                {
                    if (hand.Cards[i].Face == hand.Cards[j].Face)
                    {
                        counter++;
                    }
                }
                if (counter == 4)
                {
                    return true;
                }

                counter = 0;
            }

            return false;
        }
開發者ID:VDGone,項目名稱:TelerikAcademy-2,代碼行數:28,代碼來源:PokerHandsChecker.cs

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

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

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

示例9: TestIsValid4

        public void TestIsValid4()
        {
            IHand hand = new Hand("A♦ 10♦ Q♦ J♦ 10♦");

            PokerHandsChecker checker = new PokerHandsChecker();

            Assert.IsFalse(checker.IsValidHand(hand), "Hand validation was not successful.");
        }
開發者ID:niki-funky,項目名稱:Telerik_Academy,代碼行數:8,代碼來源:PokerHandsCheckerTest.cs

示例10: IsValidHandWithTwoCardsTest

        public void IsValidHandWithTwoCardsTest()
        {
            Hand pokerHand = new Hand(new List<ICard>(){ 
                                new Card(CardFace.Ace, CardSuit.Hearts),
                                new Card(CardFace.King, CardSuit.Diamonds)});

            PokerHandsChecker checker = new PokerHandsChecker();
            bool isValidHand = checker.IsValidHand(pokerHand);
            Assert.AreEqual(false, isValidHand);
        }
開發者ID:BorislavIvanov,項目名稱:Telerik_Academy,代碼行數:10,代碼來源:PokerHandsCheckerTest.cs

示例11: IsValidHandShouldReturnFalseIfSameCardAddedMoreThanOnce

        public void IsValidHandShouldReturnFalseIfSameCardAddedMoreThanOnce()
        {
            var hand = new Hand(deck.GetRange(0,4));
            hand.Cards.Add(deck[0]);
            var pokerHandsChecker = new PokerHandsChecker();

            var result = pokerHandsChecker.IsValidHand(hand);

            Assert.IsFalse(result);
        }
開發者ID:tddold,項目名稱:TelerikAcademy-5,代碼行數:10,代碼來源:IsValidHandTests.cs

示例12: InvalidHandWithThreeDifferentCards

        public void InvalidHandWithThreeDifferentCards()
        {
            var hand = new Hand(new List<ICard>() {
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Spades)
            });

            var checker = new PokerHandsChecker();
            Assert.IsFalse(checker.IsValidHand(hand));
        }
開發者ID:Termininja,項目名稱:TelerikAcademy,代碼行數:11,代碼來源:IsValidHandTests.cs

示例13: IsValidHandShouldReturnFalseIfTwoDifferentCardsAreEqual

        public void IsValidHandShouldReturnFalseIfTwoDifferentCardsAreEqual()
        {
            var hand = new Hand(deck.GetRange(0, 3));
            hand.Cards.Add(new Card(CardFace.Ace, CardSuit.Spades));
            hand.Cards.Add(new Card(CardFace.Ace, CardSuit.Spades));
            var pokerHandsChecker = new PokerHandsChecker();

            var result = pokerHandsChecker.IsValidHand(hand);

            Assert.IsFalse(result);
        }
開發者ID:tddold,項目名稱:TelerikAcademy-5,代碼行數:11,代碼來源:IsValidHandTests.cs

示例14: ExpectIsValidToReturnFalseWhenPokeHandIsInvalidBecauseItHasLessThanFiveCards

        public void ExpectIsValidToReturnFalseWhenPokeHandIsInvalidBecauseItHasLessThanFiveCards()
        {
            List<ICard> cards = new List<ICard>();
            cards.Add(new Card(CardFace.Ace, CardSuit.Clubs));
            cards.Add(new Card(CardFace.Ace, CardSuit.Diamonds));
            cards.Add(new Card(CardFace.Ace, CardSuit.Hearts));
            cards.Add(new Card(CardFace.Ace, CardSuit.Spades));

            Hand hand = new Hand(cards);
            PokerHandsChecker checker = new PokerHandsChecker();
            Assert.AreEqual(false, checker.IsValidHand(hand));
        }
開發者ID:Rostech,項目名稱:TelerikAcademyHomeworks,代碼行數:12,代碼來源:PokerHandsChecker_IsValidHandTests.cs

示例15: TestInvalidHand

 public void TestInvalidHand()
 {
     IList<ICard> cardList = new List<ICard>();
     cardList.Add(new Card(CardFace.King, CardSuit.Hearts));
     cardList.Add(new Card(CardFace.Queen, CardSuit.Diamonds));
     cardList.Add(new Card(CardFace.Ace, CardSuit.Spades));
     cardList.Add(new Card(CardFace.Jack, CardSuit.Clubs));
     cardList.Add(new Card(CardFace.Ace, CardSuit.Spades));
     var hand = new Hand(cardList);
     var handChecker = new PokerHandsChecker();
     Assert.AreEqual(false, handChecker.IsValidHand(hand));
 }
開發者ID:hrist0stoichev,項目名稱:Telerik-Homeworks,代碼行數:12,代碼來源:PokerHandsCheckerTests.cs


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