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


C# IHand.ToString方法代码示例

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


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

示例1: IsFlush

        public bool IsFlush(IHand hand)
        {
            if (!IsValidHand(hand))
            {
                return false;
            }

            if (hand.Cards.Count != 5)
            {
                return false;
            }

            for (int i = 0; i < 5; i++)
            {
                if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
                {
                    return false;
                }
            }
            CardSuit cardsSuit = hand.Cards[0].Suit;

            for (int j = 0; j < 5; j++)
            {
                if (hand.Cards[j].Suit != cardsSuit)
                {
                    return false;
                }
            }
            return true;
        }
开发者ID:Rostech,项目名称:TelerikAcademyHomeworks,代码行数:30,代码来源:PokerHandsChecker.cs

示例2: IsFourOfAKind

        public bool IsFourOfAKind(IHand hand)
        {
            if (!IsValidHand(hand))
            {
                return false;
            }

            int faceCounter = 1;
            int maxCounter = 0;
            String[] splitedHand = hand.ToString().Split(' ');

            for (int i = 0, len = splitedHand.Length; i < len; i++)
            {
                for (int j = i + 1; j < len; j++)
                {
                    if (splitedHand[i][0] == splitedHand[j][0])
                    {
                        faceCounter++;
                    }
                }

                if (faceCounter > maxCounter)
                {
                    maxCounter = faceCounter;
                    faceCounter = 1;
                }
            }

            if (maxCounter == 4)
                return true;
            else
                return false;
        }
开发者ID:Bvaptsarov,项目名称:Homework,代码行数:33,代码来源:PokerHandsChecker.cs

示例3: IsFlush

        public bool IsFlush(IHand hand)
        {
            if (!this.IsValidHand(hand))
            {
                return false;
            }

            string checkString = hand.ToString();
            int[] checkPlaces = new int[NumberOfSuits];
            checkPlaces[0] = checkString.IndexOf("Hearts");
            checkPlaces[1] = checkString.IndexOf("Clubs");
            checkPlaces[2] = checkString.IndexOf("Spades");
            checkPlaces[3] = checkString.IndexOf("Diamonds");
            int countOfSuits = 0;
            for (var i = 0; i < NumberOfSuits; i++)
            {
                if (checkPlaces[i] != -1)
                {
                    countOfSuits++;
                }
            }

            if (countOfSuits == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:emilti,项目名称:Telerik-Academy-My-Courses,代码行数:31,代码来源:PokerHandsChecker.cs

示例4: IsFlush

        public bool IsFlush(IHand hand)
        {
            if(!IsValidHand(hand))
            {
                return false;
            }

            String[] splitedHand = hand.ToString().Split(' ');

            for (int i = 0, len = splitedHand.Length; i < len; i++)
            {
                for (int j = i + 1; j < len; j++)
                {
                    if (splitedHand[i][1] != splitedHand[j][1])
                    {
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:Bvaptsarov,项目名称:Homework,代码行数:22,代码来源:PokerHandsChecker.cs

示例5: IsValidHand

        public bool IsValidHand(IHand hand)
        {
            if (hand == null)
            {
                return false;
            }

            if (hand.Cards.Count != 5)
            {
                return false;
            }

            byte initialCardsCount = 5;

            for (int i = 0; i < initialCardsCount; i++)
            {
                if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
                {
                    return false;
                }
            }
            return true;
        }
开发者ID:Hris21,项目名称:High-Quality-Code,代码行数:23,代码来源:PokerHandsChecker.cs

示例6: IsValidHand

        public bool IsValidHand(IHand hand)
        {
            if (hand?.Cards.Count != 5)
            {
                return false;
            }

            for (int i = 0; i < 5; i++)
            {
                if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:SimoPrG,项目名称:TelerikAcademyHomeworks,代码行数:17,代码来源:PokerHandsChecker.cs

示例7: IsValidHand

        public bool IsValidHand(IHand hand)
        {
            if (hand == null)
            {
                throw new ArgumentNullException("No hand passed");
            }

            if (hand.Cards.Count != 5)
            {
                return false;
            }

            for (int i = 0; i < 5; i++)
            {
                if (hand.ToString().IndexOf(hand.Cards[i].ToString()) != hand.ToString().LastIndexOf(hand.Cards[i].ToString()))
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:kiko81,项目名称:Teleric-Academy-Homeworks,代码行数:22,代码来源:PokerHandsChecker.cs

示例8: IsValidHand

        public bool IsValidHand(IHand hand)
        {
            String[] splitedHand = hand.ToString().Split(' ');

            if (splitedHand.Length != ValidHandCount)
            {
                return false;
            }

            for (int i = 0,len = splitedHand.Length; i < len; i++)
            {
                for (int j = i+1; j < len; j++)
                {
                    if (splitedHand[i] == splitedHand[j])
                    {
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:Bvaptsarov,项目名称:Homework,代码行数:22,代码来源:PokerHandsChecker.cs

示例9: RecognizeHandStrength

        public HandStrength RecognizeHandStrength(IHand hand)
        {
            HandStrength handStrength = HandStrength.HighCard;

            if (!IsValidHand(hand))
            {
                throw new ArgumentException("this hand is not valid: " + hand.ToString());
            }

            if (IsStraightFlush(hand))
            {
                handStrength = HandStrength.StraightFlush;
                return handStrength;
            }

            if (IsFourOfAKind(hand))
            {
                handStrength = HandStrength.FourOfAKind;
                return handStrength;
            }

            if (IsFullHouse(hand))
            {
                handStrength = HandStrength.FullHouse;
                return handStrength;
            }

            if (IsFlush(hand))
            {
                handStrength = HandStrength.Flush;
                return handStrength;
            }

            if (IsStraight(hand))
            {
                handStrength = HandStrength.Straight;
                return handStrength;
            }

            if (IsThreeOfAKind(hand))
            {
                handStrength = HandStrength.ThreeOfAKind;
                return handStrength;
            }

            if (IsTwoPairs(hand))
            {
                handStrength = HandStrength.TwoPairs;
                return handStrength;
            }

            if (IsOnePair(hand))
            {
                handStrength = HandStrength.OnePair;
                return handStrength;
            }

            return handStrength;
        }
开发者ID:DYanis,项目名称:Poker5CardDrawCompareHandsEngine,代码行数:59,代码来源:HandStrengthRecognizer.cs


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