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 += 1000000000;
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 += 5000000;
} else myPrize += 1000000;
}
else if (spade == 3 || heart == 3 || diamond == 3 || clover == 3) myPrize += 100000;
else if (spade == 2 || heart == 2 || diamond == 2 || clover == 2) {
if (spade == 2 || heart == 2 || diamond == 2 || clover == 2) {
myPrize += 50000;
} else myPrize += 1000;
}
}
void oneShot(){
roll();
samecount();
prize();
samecountreset();
}
}
public class Homework4_1 {
public static void main(String[] args) {
Slotmachine casino = new Slotmachine();
casino.gameStart();
casino.oneShot();
System.out.println();
System.out.println(casino.spade);
System.out.println(casino.heart);
System.out.println(casino.diamond);
System.out.println(casino.clover);
System.out.println(casino.myPrize);
}
}