Hello! I know the code below can be done in much better ways than presented. I am trying to make a black jack simulator of some sort. I am just starting the beginning, however my output isnt comign out right. I know this is due to the way I am looping the if statements. I am new to this, and any help will be greatly appreciated.
When I run the program, it only does Spades and Diamonds, and never goes past the number 11, even though random is supposed to select 12 + 13., and other strange things. Can someone point me in the right direction?
[ October 08, 2004: Message edited by: Sean Magee ] [ October 08, 2004: Message edited by: Sean Magee ]
When you declare the variable set, you should give it some initial value. Some friends of mine recently suggested using nonsense initial values that can never possibly occur in the program. This helps later when you need to debug because if you see the nonsense value you can track down the problem a little easier. For example you can do something like:
If the Java language got rid of the switch/case construct, it would be one step closer to purism. Almost always, these type of problems are better implemented as a Map rather than a switch/case construct.
Being the purist that I am, I haven't used a switch/case since last century some time - others might not have such a purist perspective and so will not concur.