Enum Class BetOrganization
- All Implemented Interfaces:
Serializable,Comparable<BetOrganization>,Constable,ICustomerBetService
The main.BetOrganization maintains a list of customers and their respective bets, providing
functionalities to add customers, add bets, calculate gains based on bet outcomes, and display
and save betting results.
This class is particularly useful for managing betting operations and simulating betting results.
-
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 TypeMethodDescriptionvoidAdds a new bet to the organization’s list of bets.voidaddCustomer(Customer customer) Adds a new customer to the organization.voidCalculates and updates the gains for each customer by evaluating the outcomes of their bets.voidDisplays the results of each customer’s bets to the console and saves the results to a file.static BetOrganizationReturns the enum constant of this class with the specified name.static BetOrganization[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface main.ICustomerBetService
printCustomersResultsToTextFile
-
Enum Constant Details
-
INSTANCE
The singleton instance of themain.BetOrganization.
-
-
Field Details
-
customers
-
bets
-
-
Constructor Details
-
BetOrganization
private BetOrganization()
-
-
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
-
addCustomer
-
addBet
-
calculateGainsPerCustomer
public void calculateGainsPerCustomer()Calculates and updates the gains for each customer by evaluating the outcomes of their bets.This method iterates through each customer and their bets, checking if the bet outcome matches the customer’s choice. If it does, the method calculates a payout based on the bet stake and odds, adds the payout to the customer's total gains, and updates the payout in the respective
CustomerBetobject.- Specified by:
calculateGainsPerCustomerin interfaceICustomerBetService
-
showCustomersResults
public void showCustomersResults()Displays the results of each customer’s bets to the console and saves the results to a file.This method generates a summary of each customer’s betting results, prints it to the console, and then calls
ICustomerBetService.printCustomersResultsToTextFile(String)to save the results to a text file.- Specified by:
showCustomersResultsin interfaceICustomerBetService
-