Beispiel #1
0
        static void Main(string[] args)
        {
            Cards testCards = new Cards("AS");
            string print = "5H 5C 6S 7S KD";
            Hand myHand = new Hand(print);

            Console.WriteLine(testCards.CardName);
            Console.ReadKey();
        }
 public Hand Compare(Hand black, Hand white)
 {
     if (black.Rank > white.Rank)
         return black;
     if (black.Rank < white.Rank)
         return white;
     if (black.HighCard > white.HighCard)
         return black;
     if (black.HighCard < white.HighCard)
         return white;
     return null;
 }
Beispiel #3
0
 public void IsPair()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Three, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Four, Card.CardSuit.Spades),
         new Card(Card.CardValue.Eight, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Ace, Card.CardSuit.Hearts));
     //Act
     //Assert
     Assert.AreEqual(false, hand.Rank == Hand.HandRank.Pair);
 }
Beispiel #4
0
 public void IsPairWithTwoTwosShouldReturnTrue()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Two, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Four, Card.CardSuit.Spades),
         new Card(Card.CardValue.Eight, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Ace, Card.CardSuit.Hearts));
     //Act
     //Assert
     Assert.AreEqual(true, hand.Rank == Hand.HandRank.Pair);
 }
Beispiel #5
0
 public void GetHighCardAce()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Three, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Four, Card.CardSuit.Spades),
         new Card(Card.CardValue.Eight, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Ace, Card.CardSuit.Hearts));
     //Act
     var result = hand.HighCard;
     //Assert
     Assert.AreEqual(Card.CardValue.Ace, result);
 }
Beispiel #6
0
 public void GetHighCard()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Three, Card.CardSuit.Diamonds),
         new Card(Card.CardValue.Five, Card.CardSuit.Spades),
         new Card(Card.CardValue.Nine, Card.CardSuit.Clubs),
         new Card(Card.CardValue.King, Card.CardSuit.Diamonds));
     //Act
     var result = hand.HighCard;
     //Assert
     Assert.AreEqual(Card.CardValue.King, result);
 }
Beispiel #7
0
 static void Main(string[] args)
 {
     //testing...
     Hand myCard = new Hand("10Q JQ QQ KQ AQ");
     Hand myCard1 = new Hand("5K 6K 7K 8K 9K");
     Hand myCard2 = new Hand("5K 5Q 5K 5C 9S");
     Hand myCard3 = new Hand("5K 5K 5S 9C 9H");
     Hand myCard4 = new Hand("9K 5K 7K 6K QK");
     Hand myCard5 = new Hand("5Q 6S 7Q 8K 9C");
     Hand myCard6 = new Hand("5Q 5S 5Q 8K 9C");
     Hand myCard7 = new Hand("7S 7C 8C 8C 9C");
     Hand myCard8 = new Hand("8C 8S 9K 10K JK");
     Hand myCard9 = new Hand("6K 7Q 8K 10C KQ");
     Console.ReadKey();
 }
Beispiel #8
0
 public void addStat(Hand hand)
 {
     numRuns++;
     if (hand == Hand.StraightFlush)
     {
         straightFlush++;
     }
     else if (hand == Hand.FourOfAKind)
     {
         fourOfAKind++;
     }
     else if (hand == Hand.FullHouse)
     {
         fullHouse++;
     }
     else if (hand == Hand.Flush)
     {
         flush++;
     }
     else if (hand == Hand.Straight)
     {
         straight++;
     }
     else if (hand == Hand.ThreeOfAKind)
     {
         threeOfAKind++;
     }
     else if (hand == Hand.TwoPair)
     {
         twoPair++;
     }
     else if (hand == Hand.Pair)
     {
         pair++;
     }
     else
     {
         highCard++;
     }
 }
        public void CompareHands()
        {
            var black = new Hand(
                new Card(Card.CardValue.Two, Card.CardSuit.Hearts),
                new Card(Card.CardValue.Three, Card.CardSuit.Diamonds),
                new Card(Card.CardValue.Five, Card.CardSuit.Spades),
                new Card(Card.CardValue.Nine, Card.CardSuit.Clubs),
                new Card(Card.CardValue.King, Card.CardSuit.Diamonds));

            var white = new Hand(
                new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
                new Card(Card.CardValue.Three, Card.CardSuit.Hearts),
                new Card(Card.CardValue.Four, Card.CardSuit.Spades),
                new Card(Card.CardValue.Eight, Card.CardSuit.Clubs),
                new Card(Card.CardValue.Ace, Card.CardSuit.Hearts));

            var checker = new HandChecker();

            var result = checker.Compare(black, white);

            Assert.AreEqual(white, result);
        }
Beispiel #10
0
 public void setHand()
 {
     if (checkStraightFlush())
     {
         hand = Hand.StraightFlush;
     }
     else if (checkFourOfAKind())
     {
         hand = Hand.FourOfAKind;
     }
     else if (checkFullHouse())
     {
         hand = Hand.FullHouse;
     }
     else if (checkFlush())
     {
         hand = Hand.Flush;
     }
     else if (checkStraight())
     {
         hand = Hand.Straight;
     }
     else if (checkThreeOfAKind())
     {
         hand = Hand.ThreeOfAKind;
     }
     else if (checkTwoPair())
     {
         hand = Hand.TwoPair;
     }
     else if (checkPair())
     {
         hand = Hand.Pair;
     }
     else
     {
         hand = Hand.HighCard;
     }
 }
Beispiel #11
0
 public void RankOfStraightIsStraight()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Three, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Four, Card.CardSuit.Spades),
         new Card(Card.CardValue.Five, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Six, Card.CardSuit.Hearts));
     //Act
     //Assert
     Assert.AreEqual(Hand.HandRank.Straight, hand.Rank);
 }
Beispiel #12
0
 public static Outcome Play(Hand challenger, Hand opponent)
 {
     return GameChallenge.GetOutcome(challenger, opponent);
 }
Beispiel #13
0
 static void Main(string[] args)
 {
     Hand myCard = new Hand("4D 5D 6D 7D 8D");
        myCard.pokerHand();
        Console.ReadKey();
 }
 private ComparisonOutcome CompareToSimilar(Hand otherHand)
 {
     // Get ScoringValueCount attribute value
     // Break tie accordingly
 }
Beispiel #15
0
 public void IsTwoPairsWithThreeTwosAndNoOtherMatchShouldReturnFalse()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Two, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Two, Card.CardSuit.Spades),
         new Card(Card.CardValue.Three, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Ace, Card.CardSuit.Hearts));
     //Act
     //Assert
     Assert.AreEqual(false, hand.Rank == Hand.HandRank.TwoPairs);
 }
Beispiel #16
0
 public void IsTwoPairsWithTwoTwosAndTwoThreesShouldReturnTrue()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Two, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Three, Card.CardSuit.Spades),
         new Card(Card.CardValue.Three, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Ace, Card.CardSuit.Hearts));
     //Act
     //Assert
     Assert.AreEqual(true, hand.Rank == Hand.HandRank.TwoPairs);
 }
Beispiel #17
0
 public void RankOfFlushIsNotStraight()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Three, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Four, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Five, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Jack, Card.CardSuit.Clubs));
     //Act
     //Assert
     Assert.AreEqual(Hand.HandRank.Flush, hand.Rank);
 }
Beispiel #18
0
 public void RankOfThreeTwosAndNoOtherMatchIsThreeOfAKind()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Two, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Two, Card.CardSuit.Spades),
         new Card(Card.CardValue.Three, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Ace, Card.CardSuit.Hearts));
     //Act
     //Assert
     Assert.AreEqual(Hand.HandRank.ThreeOfAKind, hand.Rank);
 }
Beispiel #19
0
 public void RankOfFourOfAKindIsNotStraight()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Queen, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Queen, Card.CardSuit.Spades),
         new Card(Card.CardValue.Queen, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Queen, Card.CardSuit.Diamonds));
     //Act
     //Assert
     Assert.AreEqual(Hand.HandRank.FourOfAKind, hand.Rank);
 }
Beispiel #20
0
 public void RankOfFullhouseIsNotThreeOfAKind()
 {
     //Arrange
     var hand = new Hand(
         new Card(Card.CardValue.Two, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Two, Card.CardSuit.Hearts),
         new Card(Card.CardValue.Two, Card.CardSuit.Spades),
         new Card(Card.CardValue.Three, Card.CardSuit.Clubs),
         new Card(Card.CardValue.Three, Card.CardSuit.Hearts));
     //Act
     //Assert
     Assert.AreNotEqual(Hand.HandRank.ThreeOfAKind, hand.Rank);
     Assert.AreEqual(Hand.HandRank.FullHouse, hand.Rank);
 }