BoimaM / semester_javaCourse_SP24

Assignments and projects from Spring 2024, independent study course
0 stars 0 forks source link

You should be calling the getPairs() method in hasFullHouse() #18

Closed mu-jchung closed 2 months ago

mu-jchung commented 2 months ago

https://github.com/BoimaM/semester_javaCourse_SP24/blob/a61621eaa1a4ed67d0e3c906fa91843415513d6c/src/project_1/Poker.java#L65

You should be calling the getPairs() method in hasFullHouse() to see if it returns 1 (for one pair).

Also, currently hasFullHouse() is not detecting full house correctly:

Hold on. I'm shuffling the deck. Here is your hand: 1 - 4 of Hearts 2 - 3 of Hearts 3 - King of Clubs 4 - 4 of Clubs 5 - 5 of Diamonds How many cards in your hand do you want to replace (0-5)? 3 Enter the number of the cards you want to replace (1-5), separated by spaces: 2 3 5 Updated hand: 1 - 4 of Hearts 2 - 4 of Spades 3 - Ace of Clubs 4 - 4 of Clubs 5 - 3 of Clubs

You have a FULL HOUSE.

BoimaM commented 2 months ago

Screen Shot 2024-04-16 at 1 25 25 PM

The Full house was detected within my IDE. Above is a screenshot for proof Professor.

mu-jchung commented 2 months ago

A full house is three-of-a-kind plus one pair. 9-9-9-Jack-Queen is not a full house.

BoimaM commented 2 months ago

public boolean hasFullHouse(PlayingCard[] hand) { //check for three of a kind boolean threeOfAKind = hasThreeOfAKind(hand); //Check for pair: int pairCount = getPairs(hand);

    return threeOfAKind && pairCount == 1;
}