A simplified version of a roulette game might involve a player that has a bankroll of money and makes bets on which number the roulette wheel lands on. For this activity, we will concentrate on setting up the basics of a Player class and the bet making process. Assume the roulette wheel:
final int BLACK = 1;Nobody reading this code will have trouble figuring out your coding scheme (that is, a black bet is coded by a 1, a red bet by 2, etc.). Enough on constants and coding string values with numbers, let's design the basic shell of our roulette player class. Our players should be able to place bets on red or black spins, as well as place bets on any single outcome (like the ball landing in slot 7). Since we'll be betting, we'll need a bankroll, or the current amount of money our player has available. We'll need a way for our player to spin the roulette wheel (for now, we'll just add a "spin" field, where the user can type in the result of the spin). In order to process our bets, we'll need a payoff method, to figure out how much we won, and update our bankroll appropriately.
final int RED = 2;
final int NUMBER_BET = 3;
int betType;// later in this class file
if (betType == BLACK){
handle a bet on black;
}
else if (betType == RED) {
handle a bet on red;
}
else if (betType == NUMBER_BET) {
handle a bet on a specific number;
}