Package main
Enum Class GameEmulator
- All Implemented Interfaces:
Serializable,Comparable<GameEmulator>,Constable
Singleton class for emulating game results by randomly selecting outcomes for a list of bets.
The main.GameEmulator provides a single instance, INSTANCE, which can be used
to generate random game results for each Bet in a given list of bets.
This class is particularly useful for simulating or testing betting outcomes.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateRandomGameResults(List<Bet> bets) Generates random results for the given list of bets and sets the result on each bet.static GameEmulatorReturns the enum constant of this class with the specified name.static GameEmulator[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
The singleton instance of themain.GameEmulator.
-
-
Field Details
-
random
ARandominstance used to generate random numbers for selecting random game results.This field is used to randomly pick the game outcome from the available choices for each bet. It is a crucial part of simulating the unpredictability of game results when testing or emulating betting outcomes.
-
-
Constructor Details
-
GameEmulator
private GameEmulator()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
generateRandomGameResults
Generates random results for the given list of bets and sets the result on each bet.This method iterates through each bet in the provided list and randomly selects a result from the available choices for that particular bet. The chosen result is then set on the corresponding bet using the
Bet.setGameResult(char)method.- Parameters:
bets- A list ofBetobjects, where each bet has a set of possible results. This method will assign a random result to each bet in the list.
-