Skip to content

Instantly share code, notes, and snippets.

@maartenl
Created October 28, 2016 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maartenl/a804f4ac435f491b57c7ae810d5fd577 to your computer and use it in GitHub Desktop.
Save maartenl/a804f4ac435f491b57c7ae810d5fd577 to your computer and use it in GitHub Desktop.
Bets on the roulette wheel.
/**
* <p>
* The pockets of the roulette wheel are numbered from 0 to 36.</p>
* <p>
* In number ranges from 1 to 10 and 19 to 28, odd numbers are red and even are black.
* In ranges from 11 to 18 and 29 to 36, odd numbers are black and even are red.</p>
* <p>
* There is a green pocket numbered 0 (zero).</p>
* <p>
* In American roulette, there is a second green pocket marked 00. But we're playing the French version.</p>
*
* @author mrbear
*/
public enum Bet
{
GREEN, BLACK, RED;
/**
* @param bet the betting number
* @return the kind of colour on that number.
*/
public static Bet getBet(int bet)
{
if (bet == 0)
{
return GREEN;
}
if ((bet >= 1 && bet <= 10) || (bet >= 19 && bet <= 28))
{
if (bet % 2 == 0)
{
return BLACK;
} else
{
return RED;
}
}
if (bet % 2 == 0)
{
return RED;
}
return BLACK;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment