Slot machine, payout random generator.

[SOLVED]

Thank you.
Last edited on
Why does the four wheel slot machine have three wheels?

Anyways, this is what's happening:

1.) If all three wheels are the same number, print "STAR STAR STAR"
Otherwise, continue to case #2

2.) If all three wheels equal two, print "BAR BAR BAR"
This case doesn't make sense, and it will never print, because if all three wheels were equal to two, then all wheels would have been the same, and the first if control structure would have been executed (STAR STAR STAR).
Otherwise, go on to case #3

3.) Same deal with the next two cases from lines 259 - 268. They will never execute.
Move on to case #5

4.)...

5.) If LEMON is equal to five, which it always is, then print "BAR BAR BAR".

The odds of printing anything other than "BAR BAR BAR", in this case, "STAR STAR STAR" is 1/216 (if my math is correct).
Last edited on
Because I was working with the three wheel twice, just using two different approaches (I was going to tidy it up and change everything to four wheel when I had gotten the three wheel working).

Now that you put it into words, I completely butchered the whole process.

Kill me now.
[removed code]
Last edited on
You need to use the wheel integers as indecies for the array.
Currently, the fruitLabels aren't being used at all.

if(fruitLabels[wheel1] == "STAR" && /**/)

Another thing I noticed is that you aren't actually adding the prize credits to the credits.
Last edited on
[removed code]
Last edited on
You can clean this up a bit by taking
credits = credits - bet;
out of all the if conditions, since it will happen every time, and putting it after you take the bet. You can do the same thing with your fruitlabels because like with deducting the bet, it will print the same thing regardless of which condition is true if you use the array indexes. That might sound confusing, but its the same thing as your last fix.
I definitely cleaned it up (I rewrote a lot of the coding to go into my "final" project - I had a few dummy source codes going on), working with one section at a time. The last code I had, I copied all the three wheel stuff to the four wheel function & added the fourth wheel and it caused my program to crash. Everything is running smoothly now, for the most part.

Only problem now is (using the most recent fix I posted above) is when I go to play & win, let's just say 25 credits... it gives me the message for that win AND the message for "losing." Is there another way of going about that?

I'm not doing it exactly the way I was told to do it (need a function for the 3 & 4 wheel, and a spin function) BUT I'm doing what's working, lol. I've worked hard just to get it this far!

Just so I'm understanding you, though. You're saying to take this:

1
2
3
4
5
        cout << "You currently have " << credits << " credits." << endl;
	cout << "How many of those credits would you like to bet? ";
	cin >> bet;
        credits = credits - bet; // and place this here? then take it out of all the if conditions?
	cout << endl;


And then the fruitlabels... you confused me on that one.
Yes exactly, anyplace between where you get the bet and the start of the ifs would work although it might be easier to read like this
1
2
3
4
cin >> bet;
cout << endl;

credits = credits - bet;


For the fruitlabels, think about what this would output
 
cout << fruitLabels[wheel1]; // edit to add semicolon 


It is completely independent of any of the if conditions so
1
2
3
4
5
6
7
cin >> bet;
cout << endl;

credits = credits - bet; 
cout << fruitLabels[wheel1]...

if(fruitlabels...


The remaining lines are dependent on the condition so they have to stay as they are, but it will be much clearer to you, or anyone else, what is going on.
Last edited on
Topic archived. No new replies allowed.