Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Need help on a tutorial challenge

Author
Message
Lifebandit
14
Years of Service
User Offline
Joined: 27th Mar 2010
Location: Texas USA
Posted: 31st Mar 2010 06:22
I have been trying to figure this challenge out now for 2 days. It walked me through creating a simple slot machine program. Original code here


Then it challenged me to change the dial numbers from 1 through 3 to 1 through 5.

Here is what I have and as you can see when you run it, it will land on a jackpot and display all msges:


Can you guys tell me where I'm going wrong?
Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 31st Mar 2010 16:10 Edited at: 31st Mar 2010 16:27
If you seperate the text (i.e. put the text strings at different y coords) you will see that in the event of a 3 of a kind you only actually get the "Three of a kind - Jackpot!" and "No matches - You Lose!" messages, not all three messages

at the moment, in your code you are running two seperate logic checks:

the first is to see if you have 3 of a kind, and the second logic check (to look for two of a kind) is run REGARDLESS of whether or not you have a 3 of a kind

so, if your numbers come up as a 3 of a kind, the first logic check is made, comes up as "true" and the 3 of a kind message is printed to screen.

Then it moves on to the next logic check, which comes up "false" for a two of a kind. Anything that ISN'T a 2 of a kind is therefore a loss, and hence the "you lose" message is generated

simply swap the first ENDIF to an ELSE, and add the ENDIF to the end to close the loop, something like this:



basically, in normal speak, you are now doing the following:

if it is 3 of a kind - do the 3 of a kind stuff
otherwise (else)
if it is 2 of a kind - do the 2 of a kind stuff
otherwise (else)
it must be a 1 of a kind - do the no match stuff

This is not the Sig you are looking for....
Lifebandit
14
Years of Service
User Offline
Joined: 27th Mar 2010
Location: Texas USA
Posted: 1st Apr 2010 02:34
I see said the blind man. I knew it had to be something simple lol. Thank you! Can I also get some constructive feedback on my logic check method? I did away with their result integer since I didn't want to write an essay in code for a simple app lol.
Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 1st Apr 2010 12:01 Edited at: 1st Apr 2010 12:02
The logic is fine, sure there are different ways to do it using case statements etc, but what you have used is perfectly functional.

It was an awesome idea to steer away from the whole 'result' variable, especially if you are using 3 numbers from 1-5.

This is not the Sig you are looking for....

Login to post a reply

Server time is: 2024-11-24 17:56:49
Your offset time is: 2024-11-24 17:56:49