ucsb-cs56-projects / cs56-pokergame

-
0 stars 3 forks source link

Fixed Four of a Kind/ Full House #8

Closed samuelechu closed 8 years ago

samuelechu commented 8 years ago

20a5e712e50ed281c524d770d08ca84ab90af407

Consider this test case @Test public void testCompareFourOfAKind() { Card card1=new Card(12,"D"); Card card2=new Card(12,"H"); Card card3=new Card(14,"C"); Card card4=new Card(12,"S"); Card card5=new Card(3,"S");

    Card card11=new Card(11,"H");
    Card card22=new Card(14,"H");

    Card card33=new Card(12,"C");
    Card card44=new Card(7,"S");

    Hand dealerHand=new Hand(card1,card2,card3,card4,card5);

    Hand player1=new Hand(card11,card22);
    Hand player2 = new Hand(card33,card44);
    Hand best1 = player1.getBestHand(dealerHand);
    Hand best2 = player2.getBestHand(dealerHand);

    assertEquals(true, best2.isFourOfAKind());
    assertEquals(false, best2.isThreeOfAKind());
    assertEquals(false, best2.isTwoPair());
    assertEquals(false, best1.isFourOfAKind());
    assertEquals(true, best1.isFullHouse());
    assertEquals(1, best2.compareHands(best1));
}

Before fixing, the hand (12D, 12H, 12S, 14C, 14H) return true for isFourOfAKind() and isFullHouse(), resulting in assertEquals(1, best2.compareHands(best1)) failing

simplified method for both isFullHouse and isFourOfAKind

shumarvin commented 8 years ago

estimate:100 pts