For my homework, I was assigned a map class that listed types for Rank and Costume. I need to compare two hands in poker (each hand is an ArrayList of 5 cards) and determine the winner.
The isStraight() function really bothers me because I have to start the countdown after Ace. For example,
QUEEN, KING, ACE, TWO, THREE
Still considered direct. What is the best way to code this function?
Here is the code for the numbered Rank / Suit 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; }
java performance poker
Logan serman
source share