I have a question involving EnumSet and Enum. More specifically, about passing them as paramaters and returning them from methods.
Basically, I want to have a method in one class create an EnumSet of certain elements of a Enum than I want said class to pass the EnumSet to another class where the new class uses logic to choose one specific element from the set and pass it to a third class that performs some desired action. If that is too confusing, I tried to provide some context below.
I'm trying to make a blackjack simulator program which has a several classes. The classes that pertain to my question are Dealer, Player, and Hand.
The issue I'm having is I want the Hand class to have an enum of options e.g.
enum Options { SPLIT, DOUBLE, HIT, STAND}
Then I want the hand to examine the contents of the hand which is an ArrayList cards (the Integer value in the array list simply represents the cards rank, suit is unimportant), to determine which options the Player object has available.
I would like a getPlayerOptions() method in the Hand class that determines the possible Options and creates an
EnumSet<Options> availableOptions = EnumSet.of(.....)
containing the available options.
I fully know how the Hand class can perform the logic and create the EnumSet I need, but I struggle to find out how to send "EnumSet availableOptions" to the player class as a paramater and than have the player class run a playerOption() method which returns one "option" to the Dealer object where dealer deals cards accordingly.
this is just a snippet without any logic but does this work for returning the enum set:
import java.util.EnumSet;
public class Hand {
enum Options {
SPLIT, FREEDOUBLE, DOUBLE, HIT, STAND
}
public EnumSet getOptions() {
EnumSet<Options> playerOptions = EnumSet.of(Options.STAND);
return playerOptions;
}
}