import java.util.Scanner; // this lets me use the scanner thingy further down
import java.util.Random;
public class slotCode
{
public static void main(String[]args)
{
Scanner scanner = new Scanner(System.in); //so apperantly this helps me process inputs
int cash = 1976; //founding year of the school bc easter eggs are coolio
int bet; //money yay
int payout; //money yay
System.out.println("Yay a Slot Machine (made with java and tears)"); //a very cool and sane intro
System.out.println("//////////////////////////////////////////////////////");
System.out.println("//////////////////////////////////////////////////////");
String[] rowItems = {":)", "!", "76", "lol", "bee"};//the thingys that pop up and tell you if you get money
System.out.print("Items: | ");
for(int i = 0; i < rowItems.length; i++)
{
System.out.print(rowItems[i] + " | ");
}
System.out.println();
while(cash > 0)
{
System.out.println("Your Current life savings:" + cash);
System.out.print("Make your bet:");
bet = scanner.nextInt();
if (bet> cash)
{
System.out.println("Bro, you are way to broke to be betting that much");
continue; //this makes you go back to beginning
}
else if(bet <= 0)
{
System.out.println("Okayyyyy uhhh so you actually need to be betting at lease SOME money");
}
else
{
cash -= bet;
}
System.out.println("/////////////////////////////////////////////////");
System.out.println("Round and round the spinners go...");
rowItems = spinLikeAWahingMachine(); //... im so good at names
System.out.print("Spinned: | ");
for(int i = 0; i < rowItems.length; i++)
{
System.out.print(rowItems[i] + " | ");
}
System.out.println();
payout = payoutReturn(rowItems, bet); // this tells you how much you made
if(payout > 0)
{
System.out.println("Yay! You're lucky and won $" + payout + "!!!!!");
cash+=payout;
}
else{
System.out.println("wow, ig you're unlucky... you'll just have to learn how to be more lucky at gambling club");
}
System.out.println("Try Again?");
}
scanner.close(); //this closes the scanner so that it doesn't run forever lol
}
static String[] spinLikeAWahingMachine()
{
String[] symbols = {":)", "!", "76", "lol", "bee"};
String[] slotRow = new String[3];
Random randy = new Random(); //gets math.random in ig
for(int i = 0; i < 3; i++)
{
slotRow[i] = symbols[randy.nextInt(symbols.length)]; //gives random image
}
return slotRow;
}
static void rowPrint(String[] row)
{
System.out.println(""+String.join(" | ", row));
}
static int payoutReturn(String[] row, int bet)
{
if(row[0].equals(row[1]) && row[0].equals(row[2])) //if they are all the same
{
return switch(row[0])
{ //detrmining the value the bet should go up depending on the item shown
case ":)" -> bet*4; //I basically just chose random ints for this
case "!" -> bet*4;
case "76" -> bet*10;
case "lol" -> bet*4;
case "bee" -> bet*20;
default -> 0;
};
}
else if(row[0].equals(row[1]) || row[1].equals(row[2])) //if two are same in a row
{
return switch(row[0])
{ //detrmining the value the bet should go up depending on the item shown
case ":)" -> bet*2;
case "!" -> bet*2;
case "76" -> bet*2;
case "lol" -> bet*2;
case "bee"-> bet*5;
default -> 0;
};
}
return 0;
}
}