Hello, for a homework assignment I was given a Card class that has enumerated types for the Rank and Suit. I am required to compare two pokerhands (each hand is an ArrayList of 5 cards) and decide the winner.
The isStraight() function is really bothering me, because I have to start over the count after the Ace. For example,
QUEEN, KING, ACE, TWO, THREE
Is still considered a straight. What is the best way to code this functionality?
Here is the Rank/Suit enumerated type code, if that helps.
public enum Rank
{
TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(8), NINE(9),
TEN(10), JACK(11), QUEEN(12), KING(13), ACE(14);
private final int points;
private Rank(int points)
{
this.points = points;
}
public int points()
{
return this.points;
}
}
public enum Suit
{
DIAMONDS, CLUBS, HEARTS, SPADES;
}