I'm working on a simple slot machine code. However, although I want the machine to return the bet amount * 2 each time there are 2 identical reels - I can see that it doesn't always obey to my instructions. I checked it for one hour and couldn't find my problem. Attached below is the relevant part of my code. Here is a screenshot of the bug: https://prnt.sc/oo69x4
Thanks!
if ( ( (reel1 == reel2) && (reel2 != reel3) ) || ( (reel1 == reel3) && (reel2 != reel3) )
|| ( (reel2 == reel3) && (reel1 != reel3) ) ) {
reelResultsDisplay += "\n\nYou won " + betAmount* 2;
player1.balance = player1.balance + betAmount* 2;
} else if ( (reel1 != reel2) && (reel2 != reel3) && (reel1 != reel3) ) {
reelResultsDisplay += "\n\nYou won 0$";
} else {
reelResultsDisplay += "\n\nYou won " + betAmount* 20;
player1.balance = player1.balance + betAmount* 20;
}
String finalNotice = "\n\nYour current balance is " + player1.balance + "$";
reelResultsDisplay += finalNotice;
// Showing the slot machine output
JOptionPane.showMessageDialog(null, reelResultsDisplay);
Aucun commentaire:
Enregistrer un commentaire