I am stuck on what feels like a seemingly simple question.
Say I have the following enum:
enum CARDS {
JOKER(1),
JACK(2),
QUEEN(3),
KING(4),
ACE(5)
;
private final int cardNumber;
CARDS(int cardNumber) {
this.cardNumber = cardNumber;
}
}
I would like to find a way to determine the value of an enum (JOKER, JACK, QUEEN, KING, ACE) using an integer that is randomly generated from a separate class. Would this be possible, and is this good practice?
For example:
I have an integer, say, 3.
I would like to match the integer to the constant value assigned to the enum, in this case my integer 3 would result in being paired to queen.