IsValidHand() public method

public IsValidHand ( IHand hand ) : bool
hand IHand
return bool
        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));
        }
Example #2
0
        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);
            }
        }
        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;
        }
        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);
        }
Example #5
0
        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));
        }
Example #6
0
        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);

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

            IPokerHandsChecker checker = new PokerHandsChecker();

            Console.WriteLine(checker.IsValidHand(hand));
            Console.WriteLine(checker.IsTwoPair(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsFourOfAKind(forhand));
            Console.WriteLine(checker.IsStraight(forhand));
        }
Example #7
0
        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);
            }
        }
        public void TestIsValid2()
        {
            IPokerHandsChecker checker = new PokerHandsChecker();
            bool validHand = checker.IsValidHand(null);

            Assert.AreEqual(false, validHand, "Hand validation was not successful.");
        }
        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));
        }
Example #10
0
        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));
        }
Example #11
0
        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);
            }
        }
        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.");
        }
        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);
        }
        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);
        }
        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);
        }
        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));
        }
        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));
        }
 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));
 }
        public void TestCheckerWithValidHand()
        {
            Hand 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),
            });

            IPokerHandsChecker checker = new PokerHandsChecker();
            Assert.AreEqual(true, checker.IsValidHand(hand));
        }
        public void InvalidHandWithFiveEqualCards()
        {
            var hand = new Hand(new List<ICard>() {
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Clubs)
            });

            var checker = new PokerHandsChecker();
            Assert.IsFalse(checker.IsValidHand(hand));
        }
        public void ValidHand()
        {
            var hand = new Hand(new List<ICard>() {
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Jack, CardSuit.Diamonds),
                new Card(CardFace.Four, CardSuit.Spades),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Spades)
            });

            var checker = new PokerHandsChecker();
            Assert.IsTrue(checker.IsValidHand(hand));
        }
        public void ExpectIsValidToReturnTrueWhenPokeHandIsValid()
        {
            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));
            cards.Add(new Card(CardFace.Queen, CardSuit.Clubs));

            Hand hand = new Hand(cards);
            PokerHandsChecker checker = new PokerHandsChecker();
            Assert.AreEqual(true, checker.IsValidHand(hand));
        }
 public void IsValidHand_TestArgumentException()
 {
     PokerHandsChecker checker = new PokerHandsChecker();
     List<ICard> cardList = new List<ICard>
     {
         new Card(CardFace.Ace,CardSuit.Diamonds),
         new Card(CardFace.King,CardSuit.Spades),
         new Card(CardFace.Ace,CardSuit.Clubs),
         new Card(CardFace.Four,CardSuit.Diamonds)
     };
     Hand hand = new Hand(cardList);
     bool isValidHand = checker.IsValidHand(hand);
 }
        public void TestIsNotValidHandIfLessThan5Cards_1()
        {
            IList<ICard> cards = new List<ICard>()
            {
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Ten, CardSuit.Hearts),
                new Card(CardFace.Jack, CardSuit.Spades)
            };

            Hand hand = new Hand(cards);
            PokerHandsChecker checker = new PokerHandsChecker();
            Assert.IsFalse(checker.IsValidHand(hand));
        }
        public void TestIsValidHand()
        {
            Hand hand = new Hand(new List<ICard>
            {
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Clubs),
                new Card(CardFace.Queen, CardSuit.Spades),
                new Card(CardFace.Ten, CardSuit.Spades)
            });
             PokerHandsChecker checker = new PokerHandsChecker();

             Assert.IsTrue(checker.IsValidHand(hand));
        }
 public void TestIsValidHandLessCards()
 {
     Card cardOne = new Card(CardFace.Two, CardSuit.Diamonds);
     Card cardTwo = new Card(CardFace.Jack, CardSuit.Hearts);
     Card cardThree = new Card(CardFace.Five, CardSuit.Spades);
     IList<ICard> cards = new List<ICard>();
     cards.Add(cardOne);
     cards.Add(cardTwo);
     cards.Add(cardThree);
     Hand hand = new Hand(cards);
     PokerHandsChecker poker = new PokerHandsChecker();
     bool isValidHand = poker.IsValidHand(hand);
     Assert.AreEqual(false, isValidHand, "IsValidHand() method in class PokerHandsChecker is not working correctly.");
 }
        public void TestIsValidHand()
        {
            IList<ICard> cards = new List<ICard>()
            {
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Six, CardSuit.Clubs),
                new Card(CardFace.Ten, CardSuit.Hearts),
                new Card(CardFace.Jack, CardSuit.Spades),
                new Card(CardFace.Ace, CardSuit.Diamonds)
            };

            Hand hand = new Hand(cards);
            PokerHandsChecker checker = new PokerHandsChecker();
            Assert.IsTrue(checker.IsValidHand(hand));
        }
        public void TestIsValidHandWithMoreThanFiveCards()
        {
            PokerHandsChecker handChecker = new PokerHandsChecker();

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

            bool result = handChecker.IsValidHand(hand);
            Assert.AreEqual(false, result);
        }
        public void TestIsValidHand()
        {
            Hand hand = new Hand(new List<ICard>{
              new Card(CardFace.Two, CardSuit.Diamonds),
              new Card(CardFace.Three, CardSuit.Diamonds),
              new Card(CardFace.Four, CardSuit.Diamonds),
              new Card(CardFace.Ace, CardSuit.Diamonds),
              new Card(CardFace.King, CardSuit.Diamonds),

              });

            PokerHandsChecker checker = new PokerHandsChecker();
            var excpected = true;
            var actual = checker.IsValidHand(hand);
            Assert.AreEqual(excpected, actual);
        }
        public void TestIsValid1()
        {
            ICard[] cards = new ICard[5]
            {
                new Card(CardFace.Five, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Jack, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Five, CardSuit.Diamonds)
            };

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

            Assert.AreEqual(true, checker.IsValidHand(hand), "Hand validation was not successful.");
        }
        public void TestIsValid3()
        {
            ICard[] cards = new ICard[3]
            {
                new Card(CardFace.Nine, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Jack, CardSuit.Clubs)
            };

            IHand hand = new Hand(cards);

            PokerHandsChecker checker = new PokerHandsChecker();
            bool validHand = checker.IsValidHand(hand);

            Assert.AreEqual(false, validHand, "Hand validation was not successful.");
        }
        public void HandWithMoreLessFiveCardsShouldNotBeValid()
        {
            var hand = new Hand(new List<ICard> {
                new Card(CardFace.Ace,CardSuit.Diamonds),
                new Card(CardFace.Nine,CardSuit.Diamonds),
                new Card(CardFace.Ace,CardSuit.Clubs),
                new Card(CardFace.Eight,CardSuit.Spades)
            });

            var pokerHandChecker = new PokerHandsChecker();

            bool expected = false;
            bool actual = pokerHandChecker.IsValidHand(hand);

            Assert.AreEqual(expected, actual);
        }
        public void IsValidHand_HandWithLessCards()
        {
            IList<ICard> cards = new List<ICard>
            {
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Spades),
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Hearts),
            };

            Hand hand = new Hand(cards);

            PokerHandsChecker checker = new PokerHandsChecker();

            Assert.IsFalse(checker.IsValidHand(hand));
        }
Example #34
0
        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));
        }
Example #35
0
        static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);

            Console.WriteLine(card);

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

            Console.WriteLine(hand);

            IPokerHandsChecker checker = new PokerHandsChecker();

            Console.WriteLine(checker.IsValidHand(hand));
            Console.WriteLine(checker.IsFlush(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsFourOfAKind(hand));
        }
Example #36
0
        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);
            Console.WriteLine((int)CardFace.Ace);
            Console.WriteLine((int)hand.Cards[0].Face);
            IPokerHandsChecker checker = new PokerHandsChecker();

            Console.WriteLine(checker.IsValidHand(hand));
            //Console.WriteLine(checker.IsOnePair(hand));
            //Console.WriteLine(checker.IsTwoPair(hand));
        }
Example #37
0
        static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);

            Console.WriteLine("Current card is: " + card + Environment.NewLine);

            ///Normal hand\\\
            IHand hand = new Hand(new List <ICard>()
            {
                new Card(CardFace.Three, CardSuit.Clubs),
                new Card(CardFace.Six, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
            });

            /////Flush\\\
            //IHand hand = new Hand(new List<ICard>() {
            //    new Card(CardFace.Ace, CardSuit.Clubs),
            //    new Card(CardFace.Ace, CardSuit.Clubs),
            //    new Card(CardFace.King, CardSuit.Clubs),
            //    new Card(CardFace.King, CardSuit.Clubs),
            //    new Card(CardFace.Seven, CardSuit.Clubs),
            //});

            /////Four of a kind\\\
            //IHand hand = new Hand(new List<ICard>() {
            //    new Card(CardFace.Ace, CardSuit.Clubs),
            //    new Card(CardFace.Ace, CardSuit.Diamonds),
            //    new Card(CardFace.Ace, CardSuit.Hearts),
            //    new Card(CardFace.Ace, CardSuit.Spades),
            //    new Card(CardFace.Eight, CardSuit.Clubs),
            //});

            /////One pair\\\
            //IHand hand = new Hand(new List<ICard>() {
            //    new Card(CardFace.Ace, CardSuit.Clubs),
            //    new Card(CardFace.Ace, CardSuit.Diamonds),
            //    new Card(CardFace.Five, CardSuit.Hearts),
            //    new Card(CardFace.Jack, CardSuit.Spades),
            //    new Card(CardFace.Eight, CardSuit.Clubs),
            //});

            /////Two pairs\\\
            //IHand hand = new Hand(new List<ICard>() {
            //    new Card(CardFace.Ace, CardSuit.Clubs),
            //    new Card(CardFace.Ace, CardSuit.Diamonds),
            //    new Card(CardFace.Five, CardSuit.Hearts),
            //    new Card(CardFace.Jack, CardSuit.Spades),
            //    new Card(CardFace.Jack, CardSuit.Clubs),
            //});

            /////Straight Flush\\\
            //IHand hand = new Hand(new List<ICard>() {
            //    new Card(CardFace.Jack, CardSuit.Clubs),
            //    new Card(CardFace.Ten, CardSuit.Clubs),
            //    new Card(CardFace.Nine, CardSuit.Clubs),
            //    new Card(CardFace.Eight, CardSuit.Clubs),
            //    new Card(CardFace.Seven, CardSuit.Clubs),
            //});

            /////Full House\\\
            //IHand hand = new Hand(new List<ICard>() {
            //    new Card(CardFace.Six, CardSuit.Diamonds),
            //    new Card(CardFace.Six, CardSuit.Hearts),
            //    new Card(CardFace.Nine, CardSuit.Clubs),
            //    new Card(CardFace.Nine, CardSuit.Spades),
            //    new Card(CardFace.Nine, CardSuit.Clubs),
            //});

            /////Straight\\\
            //IHand hand = new Hand(new List<ICard>() {
            //    new Card(CardFace.King, CardSuit.Diamonds),
            //    new Card(CardFace.Queen, CardSuit.Hearts),
            //    new Card(CardFace.Jack, CardSuit.Clubs),
            //    new Card(CardFace.Ten, CardSuit.Spades),
            //    new Card(CardFace.Nine, CardSuit.Clubs),
            //});

            Console.WriteLine(hand + Environment.NewLine);

            IPokerHandsChecker checker = new PokerHandsChecker();

            Console.WriteLine("Is this hand valid: " + checker.IsValidHand(hand));
            Console.WriteLine("Do you have one pair: " + checker.IsOnePair(hand));
            Console.WriteLine("Do you have two pairs: " + checker.IsTwoPair(hand));
            Console.WriteLine("Do you have a flush: " + checker.IsFlush(hand));
            Console.WriteLine("Do you have four of a kind: " + checker.IsFourOfAKind(hand));
            Console.WriteLine("Do you have three of a kind: " + checker.IsThreeOfAKind(hand));
            Console.WriteLine("Do you have straight flush: " + checker.IsStraightFlush(hand));
            Console.WriteLine("Do you have a full house: " + checker.IsFullHouse(hand));
            Console.WriteLine("Do you have a straight: " + checker.IsStraight(hand));
            Console.WriteLine("Do you have high card: " + checker.IsHighCard(hand));
        }