import java.util.Random;
public class Slotmachine {
private int chance;
boolean liveordie = true;
String[] shapes = new String[]{"♠", "♥", "♣", "◆"};
String[] myShapes = new String[getChance()];
int myPrize = 0;
int spade;
int heart;
int diamond;
int clover;
void setChance(int a){
chance = a;
}
int getChance(){
return chance;
}
void gameStart() {
setChance(5);
System.out.println("Game Start!");
System.out.println("Your have " + getChance() + " chance");
System.out.println("Good luck!");
}
void roll(){
String[] randomShapes = new String[getChance()];
for (int i = 0; i < getChance(); i++){
String oneShape = shapes[(int)(Math.random() * getChance() - 1)];
randomShapes[i] = oneShape;
System.out.print(randomShapes[i]);
} System.out.println();
myShapes = randomShapes;
}
void samecount(){
for (int i = 0; i < getChance(); i++){
if (myShapes[i] == "♠") {
spade += 1;
} else if (myShapes[i] == "♥") {
heart += 1;
} else if (myShapes[i] == "♣") {
clover += 1;
} else if (myShapes[i] == "◆") {
diamond += 1;
}
}
}
void samecountreset(){
spade = 0;
heart = 0;
diamond = 0;
clover = 0;
}
void prize(){
if (spade == 5 || heart == 5 || diamond == 5 || clover == 5) myPrize += 100000000;
else if (spade == 4 || heart == 4 || diamond == 4 || clover == 4) myPrize += 10000000;
else if (spade == 3 || heart == 3 || diamond == 3 || clover == 3) {
if (spade == 2 || heart == 2 || diamond == 2 || clover == 2) {
myPrize += 500000;
} else myPrize += 100000;
}
else if (spade == 2 || heart == 2 || diamond == 2 || clover == 2) {
if (spade == 2) {
if (heart == 2 || diamond == 2 || clover == 2) myPrize += 50000;
else myPrize += 1000;
}
else if (heart == 2) {
if (spade == 2 || diamond == 2 || clover == 2) myPrize += 50000;
else myPrize += 1000;
}
else if (diamond == 2) {
if (spade == 2 || heart == 2 || clover == 2) myPrize += 50000;
else myPrize += 1000;
}
else if (clover == 2) {
if (spade == 2 || heart == 2 || diamond == 2) myPrize += 50000;
else myPrize += 1000;
}
} else if (spade == 1 || heart == 1 || diamond == 1 || clover == 1) myPrize += 100;
}
void oneShot(){
roll();
samecount();
prize();
}
}
``