import java.util.*;
public class WSoS {
static Scanner in = new Scanner(System.in);
public static void main(String[] args){
playSlots();
}
public static void playSlots(){ //plays the entire game of slots
int numTokens = 0, bet = 0, moneyWon; // number of tokens, the amount of tokens use wants to bet, the amount of money that the player won from the slot roll
char play = 'n', again = 'n';
String letter = "";
System.out.print("The World Series of Slots Machine! \n\n");
do{
System.out.print("How many tokens are you buying? ");
numTokens = in.nextInt();
if(numTokens System.out.print("You must buy at least one Token to play in the World Series of Slots.\n\n");
}while(numTokens do{
in.nextLine();
do{
System.out.print("You have " + numTokens + " tokens. Would you like to play? (y/n): ");
letter = in.nextLine();
play = letter.charAt(0);
if(!(play == 'n' || play == 'y'))
System.out.print("Invalid Entry. Please try again. \n\n");
}while(!(play == 'n' || play == 'y'));
if(play == 'y'){
do{
System.out.print("How many tokens would you like to bet? ");
bet = in.nextInt();
if(bet > numTokens || bet System.out.print("Nice Try! You have " + numTokens + " tokens. You must bet something. \n");
}while(bet > numTokens || bet System.out.print("\nYou have bet " + bet + " tokens... Good Luck! \n\n");
moneyWon = spinSlots(bet);
if(moneyWon == 0)
numTokens -= bet;
else
numTokens += moneyWon;
}
if(numTokens == 0){
do{
System.out.print("You are out of tokens. Would you like to buy more? (y/n): ");
in.nextLine();
letter = in.nextLine();
again = letter.charAt(0);
if(!(again == 'n' || again == 'y'))
System.out.print("Invalid Entry. Please try again. \n\n");
}while(!(again == 'n' || again == 'y'));
}
}while(play == 'y');
System.out.print("Thanks for playing!");
}
public static int spinSlots(int bet){ //uses the randomizer to determine if the player won, then calulates how much money the slot produces
Random r = new Random();
int winnings = 0, slot[] = {0, 0, 0};
System.out.print("\tSPIN:");
for(int i = 0; i < 3; i++){
slot[i] = r.nextInt(9) + 1;
System.out.print(" [" + slot[i] + "]");
}
System.out.print("\n\n");
if(slot[1] == slot[2] && slot[1] == slot[3]){
if(slot[1] == 5){
winnings = bet;
System.out.print("You have won " + winnings + "tokens! Go You!\n\n");
}
else if(slot[1] == 2){
winnings = bet * 2;
System.out.print("You have won " + winnings + "tokens! Awsome!\n\n");
}
else if(slot[1] == 7){
winnings = bet * 3;
System.out.print("You have won " + winnings + "tokens! YOUR THE BEST SLOTTER EVER!\n\n");
}
else
System.out.print("Too bad.. you lost. Try again and you might win~\n\n");
}
else
System.out.print("Too bad.. you lost. Try again and you might win~\n\n");
return(winnings);
}
}
public class WSoS {
static Scanner in = new Scanner(System.in);
public static void main(String[] args){
playSlots();
}
public static void playSlots(){ //plays the entire game of slots
int numTokens = 0, bet = 0, moneyWon; // number of tokens, the amount of tokens use wants to bet, the amount of money that the player won from the slot roll
char play = 'n', again = 'n';
String letter = "";
System.out.print("The World Series of Slots Machine! \n\n");
do{
System.out.print("How many tokens are you buying? ");
numTokens = in.nextInt();
if(numTokens System.out.print("You must buy at least one Token to play in the World Series of Slots.\n\n");
}while(numTokens do{
in.nextLine();
do{
System.out.print("You have " + numTokens + " tokens. Would you like to play? (y/n): ");
letter = in.nextLine();
play = letter.charAt(0);
if(!(play == 'n' || play == 'y'))
System.out.print("Invalid Entry. Please try again. \n\n");
}while(!(play == 'n' || play == 'y'));
if(play == 'y'){
do{
System.out.print("How many tokens would you like to bet? ");
bet = in.nextInt();
if(bet > numTokens || bet System.out.print("Nice Try! You have " + numTokens + " tokens. You must bet something. \n");
}while(bet > numTokens || bet System.out.print("\nYou have bet " + bet + " tokens... Good Luck! \n\n");
moneyWon = spinSlots(bet);
if(moneyWon == 0)
numTokens -= bet;
else
numTokens += moneyWon;
}
if(numTokens == 0){
do{
System.out.print("You are out of tokens. Would you like to buy more? (y/n): ");
in.nextLine();
letter = in.nextLine();
again = letter.charAt(0);
if(!(again == 'n' || again == 'y'))
System.out.print("Invalid Entry. Please try again. \n\n");
}while(!(again == 'n' || again == 'y'));
}
}while(play == 'y');
System.out.print("Thanks for playing!");
}
public static int spinSlots(int bet){ //uses the randomizer to determine if the player won, then calulates how much money the slot produces
Random r = new Random();
int winnings = 0, slot[] = {0, 0, 0};
System.out.print("\tSPIN:");
for(int i = 0; i < 3; i++){
slot[i] = r.nextInt(9) + 1;
System.out.print(" [" + slot[i] + "]");
}
System.out.print("\n\n");
if(slot[1] == slot[2] && slot[1] == slot[3]){
if(slot[1] == 5){
winnings = bet;
System.out.print("You have won " + winnings + "tokens! Go You!\n\n");
}
else if(slot[1] == 2){
winnings = bet * 2;
System.out.print("You have won " + winnings + "tokens! Awsome!\n\n");
}
else if(slot[1] == 7){
winnings = bet * 3;
System.out.print("You have won " + winnings + "tokens! YOUR THE BEST SLOTTER EVER!\n\n");
}
else
System.out.print("Too bad.. you lost. Try again and you might win~\n\n");
}
else
System.out.print("Too bad.. you lost. Try again and you might win~\n\n");
return(winnings);
}
}
Published by Chris Chen
Chris is currently attending the University of California, Berkeley seeking an undergraduate's degree in Electrical Engineering Computer Science. He enjoys playing basketball, practicing kendo, hanging out w... View profile
- 2008 World Series Pits Phillies against RaysThe 2008 World Series features the Philadelphia Phillies and the Tampa Bay Rays.
- Why is the World Series a Best-of-7 Series?4-World Series were played under a "Best-of-9" scenario, and three went to 8 games - including the first. What happened to the Best-of-9 concept?
- Giants and A's Postpone World Series Game Because the Crowd was Too SmallWhen Giants' manager John McGraw saw the lack of paying customers, he and Athletics' captain Lave Cross decided to call Game 3 of the 1905 World Series
Colorado Rockies vs. Boston Red Sox World Series PreviewThe 2007 World Series will feature the NL Champions, the Colorado Rockies, against the AL Champion Boston Red Sox.- Errors in World Series HistoryThe World Series is known for setting records, but the one you don't want to set is for errors. Read about the famous and the not-so-famous errors in the history of the game. From Schmidt to Buckner, one error makes a...
- Playing Online Slots
- Winning at Video Slots: The Cain Method of Slot Play
- Guide to Playing Slots
- Joe Black and Jim Konstanty: The National League's Best Relief Pitchers Opened the...
- Preview: 2008 World Series of Poker Main Event Final Table
- Home Field was Not an Advantage in Four Consecutive World Series
- The 2008 World Series Schedule of Games, Dates, and Locations
