Package bet
Class Bet
java.lang.Object
bet.Bet
- Direct Known Subclasses:
BasketballBet,FootballBet
Represents a generic betting option for a sports game, with specific odds, choices,
and a result that can be set once the game outcome is determined.
This abstract class serves as a base for different types of bets, such as BasketballBet
and FootballBet, each having distinct choices and outcome possibilities based on the
type of sport. It encapsulates common properties like the game description, odds, available choices,
and the final result.
The available choices are represented as characters:
- For football bets: '1' for a win by the home team, 'X' for a draw, and '2' for an away team win.
- For basketball bets: '1' for a win by the first team and '2' for a win by the second team.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final char[]An array of characters representing the possible outcomes for the bet.private final StringAStringdescribing the game matchup (e.g., "Team A vs Team B").private charThe final result of the game associated with this bet.private final doubleThe decimal odds associated with this bet, used to calculate potential payouts. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar[]Retrieves the available choices for this bet.charRetrieves the final result of the game associated with this bet.doublegetOdds()Retrieves the odds associated with this bet.voidsetGameResult(char gameResult) Sets the result of the game for this bet.
-
Field Details
-
game
-
odds
private final double oddsThe decimal odds associated with this bet, used to calculate potential payouts. -
availableChoices
private final char[] availableChoicesAn array of characters representing the possible outcomes for the bet.This array varies depending on the type of sport. For example:
- For football: '1', 'X', '2'.
- For basketball: '1', '2'.
-
gameResult
private char gameResultThe final result of the game associated with this bet.Initially set to '-', indicating the result is not yet determined. This value is updated using the
setGameResult(char)method once the game outcome is known.
-
-
Constructor Details
-
Bet
Constructs a newBetinstance with the specified game details, odds, and available choices.- Parameters:
game- AStringdescribing the game matchup (e.g., "Team A vs Team B").odds- The decimal odds for this bet.availableChoices- An array of characters representing the possible outcomes for the bet.
-
-
Method Details
-
getOdds
public double getOdds()Retrieves the odds associated with this bet.- Returns:
- The odds for this bet as a
double.
-
getGameResult
public char getGameResult()Retrieves the final result of the game associated with this bet.- Returns:
- The game result as a
char; '-' if the result is not yet set.
-
setGameResult
public void setGameResult(char gameResult) Sets the result of the game for this bet.This should be one of the values in
getAvailableChoices(), representing the outcome as per the betting choices defined for the specific sport type.- Parameters:
gameResult- Acharrepresenting the outcome of the game.
-
getAvailableChoices
public char[] getAvailableChoices()Retrieves the available choices for this bet.- Returns:
- An array of
charvalues representing the possible outcomes for this bet.
-