Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
RussianRouletteProgram
1. /************************************************************************************
****************************
* Amy Baxter
* Jave program
*
*
* The program is designed to run a roullette game in which the user can place bets
and gain or lose money.
*************************************************************************************
**************************/
import java.util.Random;
import java.util.Scanner;
public class roullette {
public static void main(String[] args)
{
//delcare variables
int choice;
int bet;
boolean win;
int cash = 100;
boolean flag = false;
displayWelcome();
Scanner stdIn = new Scanner(System.in);
while (flag == false) {
choice = getMenuChoice(stdIn);
bet = getBet(stdIn, cash);
if (choice == 1) {
win = playNumberBet(stdIn);
if (win == true) {
cash = cash + bet * 35;
System.out.println("COngratulations! You won, you
have $"
+ cash);
}
else {
cash = cash - bet;
System.out
.println("Sorry! You lose! You now have
$" + cash);
}
}
// end if
// begin color bet
2. if (choice == 2) {
win = playColorBet(stdIn);
if (win == true) {
cash = cash + bet * 1;
System.out.println("COngratulations! You won, you
have $"
+ cash);
}
else {
cash = cash - bet;
System.out
.println("Sorry! You lose! You now have
$" + cash);
}
}
// end if #2
if (choice == 3) {
flag = true;
System.out.println("Cash Out!!! You leave with $" + cash);
}
if (cash <= 0) {
flag = true;
System.out.println("You're super duper broke!");
}
}
System.out.println("Thanks for Playing!");
}
// end main
public static void displayWelcome() {
System.out.println("############################n"
+ "# WELCOME TO ROULETTE #n"
+ "############################n"
+ "# NUMBER BETS PAYOUT: 35:1 #n"
+ "# COLOR BETS PAYOUT: 1:1 #n"
+ "############################");
}
public static int getMenuChoice(Scanner stdIn) {
System.out.println("---Choose a Bet---n" + "1. pick a numbern"
+ "2. pick a colourn" + "3. cash out.n");
boolean flag = false;
int input = 0;
while (flag == false) {
System.out.println("Enter a choice (1-3):");
input = stdIn.nextInt();
3. if (input == 1 || input == 2 || input == 3) {
flag = true;
}
}
return input;
}
// end method
public static int getBet(Scanner stdIn, int cash) {
boolean flag = false;
int input = 0;
while (flag == false) {
System.out.println("Enter your bet ( 1-" + cash + "):");
input = stdIn.nextInt();
if (input > 0 && input <= cash) {
flag = true;
}
}
return input;
}
// end method
public static int spin() {
Random generator = new Random();
int roll = generator.nextInt(37);
return roll;
}
// end method
public static boolean playNumberBet(Scanner stdIn) {
int spin = spin();
int input = 0;
boolean flag = false;
while (flag == false) {
System.out.println("Enter a number (0-36): ");
input = stdIn.nextInt();
if (input >= 0 && input <= 36) {
flag = true;
}
}
// end while loop
String color = determinColor(spin);
if (input == spin) {
System.out.println("Congrats you won! you rolled a " + color + "
"
+ spin);
4. return true;
}
else {
System.out.println("Sorry you lost! You spun a " + color + " "
+ spin);
return false;
}
}// end method
public static boolean playColorBet(Scanner stdIn) {
int spin = spin();
String input;
boolean flag = false;
do {
System.out.println("Enter a color (red or black): ");
input = stdIn.next();
input = input.toLowerCase();
if (input.equals("red") || input.equals("black")) {
flag = true;
}
} while (flag == false);// end while loop
String color = determinColor(spin);
if (color.equals(input)) {
System.out.println("Congrats you won! you rolled a " + color + "
"
+ spin);
return true;
}
else {
System.out.println("Sorry you lost! You spun a " + color + " "
+ spin);
return false;
}
}
// end method
public static String determinColor(int color) {
if (color % 2 == 0) {
return "red";
}
else {