https://i.stack.imgur.com/5bPS6.jpg
So pretty much i've been trying to program this slot machine game in java and i've been recently having issues with the method that i'm trying to approach this solution. The game works as follows: everytime you click on the label named x1 you invest 1 bitcoin and have a higher chance to win and win 1 bitcoin. clicking on label x3 you get to play with a medium chance to win(you win 3 bitcoin), and if label x5 is clicked you'll get the lowest chance of winning 5 bitcoin. 1 click on those labels enables the button "GO WIN!", which later on you have to click in order everything to run. At the moment I have no issue with programming it to make you win only 1 bitcoin with a certain chance, although the other two labels are the issue. any advice?
The jframe looks bad I know, although this is just practice for me :)
Code so far:
// TODO add your handling code here:
btnWinLose.setEnabled(false);
int slot1 = (int)(4*Math.random()+0);
int slot2 = (int)(4*Math.random()+0);
int slot3 = (int)(4*Math.random()+0);
lbl_1.setText(String.valueOf(slot1));
lbl_2.setText(String.valueOf(slot2));
lbl_3.setText(String.valueOf(slot3));
if(slot1 == slot2 ){
start = start +1;
lbl_Coin.setText(start + " COINS");
}
else{
start = start - 1;
lbl_Coin.setText(start + " COINS");
}
if(start == 0){
int n = JOptionPane.showConfirmDialog(
this,
"No coins left, start again?"+
JOptionPane.YES_NO_OPTION);
if(n == 0){
start=10;
lbl_Coin.setText(String.valueOf(start + " COINS"));
}
else{
System.exit(0);
}
}