IsTwoPair() public method

public IsTwoPair ( IHand hand ) : bool
hand IHand
return bool
Exemplo n.º 1
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);
            }
        }
        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));
        }
        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));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
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);

            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);
        }
Exemplo n.º 6
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 TwoPairHand()
        {
            var hand = 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.Queen, CardSuit.Clubs)
            });

            var checker = new PokerHandsChecker();
            Assert.IsTrue(checker.IsTwoPair(hand));
        }
Exemplo n.º 8
0
 public void TestIsTwoPairLessCards()
 {
     Card cardOne = new Card(CardFace.Two, CardSuit.Diamonds);
     Card cardTwo = new Card(CardFace.Two, CardSuit.Hearts);
     Card cardThree = new Card(CardFace.Ten, 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 isTwoPair = poker.IsTwoPair(hand);
     Assert.AreEqual(false, isTwoPair, "IsTwoPair() method in class PokerHandsChecker is not working correctly.");
 }
        public void TestIsTwoPairWithFourOfAKind()
        {
            PokerHandsChecker handChecker = new PokerHandsChecker();

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

            bool result = handChecker.IsTwoPair(hand);
            Assert.AreEqual(false, result);
        }
Exemplo n.º 10
0
        static void Main()
        {
            ICard[] cards = new ICard[]
                {
                    new Card(CardFace.Queen, CardSuit.Hearts),
                    new Card(CardFace.Queen, CardSuit.Spades),
                    new Card(CardFace.Ten, CardSuit.Hearts),
                    new Card(CardFace.Queen, CardSuit.Diamonds),
                    new Card(CardFace.Queen, CardSuit.Clubs)
                };

            IHand hand = new Hand(cards);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine(checker.IsValidHand(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsTwoPair(hand));
        }
        public void FullHouseAcesAndTens()
        {
            IList<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.Ten, CardSuit.Spades));
            cards.Add(new Card(CardFace.Ten, CardSuit.Clubs));

            Hand hand = new Hand(cards);

            PokerHandsChecker checker = new PokerHandsChecker();

            bool result = checker.IsTwoPair(hand);
            bool expected = false;

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 12
0
        static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(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));
        }
        public void TwoKingsAndTwoJacks()
        {
            IList<ICard> cards = new List<ICard>();
            cards.Add(new Card(CardFace.King, CardSuit.Clubs));
            cards.Add(new Card(CardFace.King, CardSuit.Diamonds));
            cards.Add(new Card(CardFace.Jack, CardSuit.Hearts));
            cards.Add(new Card(CardFace.Jack, CardSuit.Spades));
            cards.Add(new Card(CardFace.Ace, CardSuit.Clubs));

            Hand hand = new Hand(cards);

            PokerHandsChecker checker = new PokerHandsChecker();

            bool result = checker.IsTwoPair(hand);
            bool expected = true;

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 14
0
        public 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("Is valid hand ? - {0}", checker.IsValidHand(hand));
            Console.WriteLine("Has one pair ? - {0}", checker.IsOnePair(hand));
            Console.WriteLine("Has two pair ? - {0}", checker.IsTwoPair(hand));
        }
Exemplo n.º 15
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);

            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);
        }
        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.Two, CardSuit.Clubs),
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Spades),
            });
            Console.WriteLine(hand);

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

        }
Exemplo n.º 17
0
        public void IsTwoPairTest()
        {
            Card aceClubs = new Card(CardFace.Ace, CardSuit.Clubs);
            Card kingClubs = new Card(CardFace.King, CardSuit.Clubs);
            Card kingHearts = new Card(CardFace.King, CardSuit.Hearts);
            Card jackClubs = new Card(CardFace.Jack, CardSuit.Clubs);
            Card aceHearts = new Card(CardFace.Ace, CardSuit.Hearts);

            List<ICard> cardsInHand = new List<ICard>();

            cardsInHand.Add(aceHearts);
            cardsInHand.Add(aceClubs);
            cardsInHand.Add(jackClubs);
            cardsInHand.Add(kingClubs);
            cardsInHand.Add(kingHearts);

            IHand hand = new Hand(cardsInHand);

            PokerHandsChecker handsChecker = new PokerHandsChecker();

            Assert.IsTrue(handsChecker.IsTwoPair(hand));
        }
Exemplo n.º 18
0
        public void IsNotTwoPairTest()
        {
            Card twoOfHearts = new Card(CardFace.Two, CardSuit.Hearts);
            Card aceOfSpades = new Card(CardFace.Ace, CardSuit.Spades);
            Card fourOfHearts = new Card(CardFace.Four, CardSuit.Hearts);
            Card fiveOfClubs = new Card(CardFace.Five, CardSuit.Clubs);
            Card tenOfHearts = new Card(CardFace.Ten, CardSuit.Hearts);

            List<ICard> cardsInHand = new List<ICard>();

            cardsInHand.Add(twoOfHearts);
            cardsInHand.Add(aceOfSpades);
            cardsInHand.Add(fourOfHearts);
            cardsInHand.Add(fiveOfClubs);
            cardsInHand.Add(tenOfHearts);

            IHand hand = new Hand(cardsInHand);

            PokerHandsChecker handsChecker = new PokerHandsChecker();

            Assert.IsFalse(handsChecker.IsTwoPair(hand));
        }
Exemplo n.º 19
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));
        }
        public void IsTwoPairsTestValidHand()
        {
            PokerHandsChecker checker = new PokerHandsChecker();

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

            bool expectedIsTwoPairs = true;
            bool actual;
            actual = checker.IsTwoPair(hand);
            Assert.AreEqual(expectedIsTwoPairs, actual);
        }
        public void TestIsTwoPairShouldReturnTrue()
        {
            var checker = new PokerHandsChecker();
            var cards = new List<ICard>
            {
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Five, CardSuit.Hearts)
            };
            var hand = new Hand(cards);

            Assert.IsTrue(checker.IsTwoPair(hand));
        }
        public void TestIsTwoPairShouldReturnFalseWhenNotMatchingHandPassed_OnePair()
        {
            var checker = new PokerHandsChecker();
            var cards = new List<ICard>
            {
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.Five, CardSuit.Hearts)
            };
            var hand = new Hand(cards);

            Assert.IsFalse(checker.IsTwoPair(hand));
        }
        public void HighCard()
        {
            IList<ICard> cards = new List<ICard>();
            cards.Add(new Card(CardFace.Two, CardSuit.Clubs));
            cards.Add(new Card(CardFace.Three, CardSuit.Diamonds));
            cards.Add(new Card(CardFace.Five, CardSuit.Hearts));
            cards.Add(new Card(CardFace.King, CardSuit.Spades));
            cards.Add(new Card(CardFace.Queen, CardSuit.Diamonds));

            Hand hand = new Hand(cards);

            PokerHandsChecker checker = new PokerHandsChecker();

            bool result = checker.IsTwoPair(hand);
            bool expected = false;

            Assert.AreEqual(expected, result);
        }
 public void TestPokerCheckerTwoPairHand()
 {
     List<ICard> cards = new List<ICard>();
     cards.Add(new Card(CardFace.Queen, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Queen, CardSuit.Hearts));
     cards.Add(new Card(CardFace.Seven, CardSuit.Spades));
     cards.Add(new Card(CardFace.Six, CardSuit.Clubs));
     cards.Add(new Card(CardFace.Six, CardSuit.Spades));
     var hand = new Hand(cards);
     var checker = new PokerHandsChecker();
     Assert.IsTrue(checker.IsTwoPair(hand));
 }
        public void TestTwoPair2()
        {
            IHand hand = new Hand("K♥ K♦ 9♦ 3♦ 3♠");

            PokerHandsChecker checker = new PokerHandsChecker();

            Assert.IsTrue(checker.IsTwoPair(hand), "Two pair is not identified correctly.");
        }
Exemplo n.º 26
0
        public void IsTwoPair_ReturnsFalseOnThreeOfAKind()
        {
            IList<ICard> cards = new List<ICard>();
            cards.Add(new Card(CardFace.Five, CardSuit.Spades));
            cards.Add(new Card(CardFace.Queen, CardSuit.Clubs));
            cards.Add(new Card(CardFace.Jack, CardSuit.Hearts));
            cards.Add(new Card(CardFace.Queen, CardSuit.Hearts));
            cards.Add(new Card(CardFace.Queen, CardSuit.Diamonds));

            IHand hand = new Hand(cards);

            PokerHandsChecker checker = new PokerHandsChecker();
            bool isTwoPair = checker.IsTwoPair(hand);
            Assert.AreEqual(false, isTwoPair);
        }
 public void IsTwoPairTest()
 {
     PokerHandsChecker target = new PokerHandsChecker();
     IList<ICard> cards = new List<ICard>();
     cards.Add(new Card(CardFace.King, CardSuit.Hearts));
     cards.Add(new Card(CardFace.King, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Nine, CardSuit.Hearts));
     cards.Add(new Card(CardFace.Nine, CardSuit.Diamonds));
     cards.Add(new Card(CardFace.Jack, CardSuit.Clubs));
     IHand hand = new Hand(cards);
     bool expected = true;
     bool actual;
     actual = target.IsTwoPair(hand);
     Assert.AreEqual(expected, actual);
 }
Exemplo n.º 28
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));
        }
        public void TwoPairCheckerShouldReturnTrueWhenHandIsValidTwoPair()
        {
            IPokerHandsChecker checker = new PokerHandsChecker();
            IHand hand = new Hand(new List<ICard>()
            {
                new Card(CardFace.Eight, CardSuit.Diamonds),
                new Card(CardFace.Eight, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Five, CardSuit.Clubs),
                new Card(CardFace.Five, CardSuit.Diamonds)
            });
            bool result = checker.IsTwoPair(hand);
            bool expected = true;

            Assert.AreEqual(result, expected);
        }
Exemplo n.º 30
0
        public void IsTwoPairNullTest()
        {
            PokerHandsChecker handsChecker = new PokerHandsChecker();

            Assert.IsFalse(handsChecker.IsTwoPair(null));
        }