IsFlush boolean
I have this method IsFlush
that checks if the card is flush. I also have another method SuitHist
that creates a histogram of how many Suits are in the hand. The goal IsFlush
is to count the Suits in the array, and if 5 or more Suits are the same, return true. However, when I try to initialize SuitHist
to an Integer array flush
, the SuitHist parameter gives an error, any help I can get with this?
public static int[] SuitHist(Card[] hand) {
int[] histSuit = new int[4];
for (int i = 0; i < hand.length; i++) {
histSuit[hand[i].suit]++;
}
return histSuit;
}
public static boolean IsFlush(Cards[] deck) {
int[] flush = SuitHist(deck);
for (int i = 0; i < flush.length; i++) {
for (i = 0; i < 4; i++) {
if (flush[i] >= 5)
return true;
}
}
return false;
}
I think you have a typo. SuitHist
expects an array of type Card[]
, but in IsFlush
you have a deck of type Cards[]
. Try changing the function like this:
public static boolean IsFlush(Card[] deck){
....
}