• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calculating values with multiple conditions.

 
Rene Rad
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a blackjack game and am trying to calculate the values but Ace = high or low is throwing me off. I can account for if there is 1 ace in the hand but if a second pops up my previous code couldn't handle that. I've tryed to adjust the code to use a for each loop but I can't get it working.

Below is what I have. Can anyone point me in the right direction?

Thanks.

 
Bert Wilkinson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This method has some hope....but it's not going to work. You're looping through the deck within a loop of the deck....so you're probably getting some crazy answers on this. You need to rethink this and think about all the possible cases. What will you do if you have 2 aces in one hand?

Maybe rephrasing that question will lead you in the right direction: If you knew after going through your hand that you had 2 aces, how would that affect your summation?

good luck. And remember: You'll learn more and get better responses if you post the results of executing your code.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or better yet, move the definition of what constitutes an "Ace" into the card itself... or even the game (consider wildcards).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic