aspose file tools*
The moose likes Beginning Java and the fly likes calculating values with multiple conditions. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "calculating values with multiple conditions." Watch "calculating values with multiple conditions." New topic
Author

calculating values with multiple conditions.

Rene Rad
Greenhorn

Joined: Feb 10, 2010
Posts: 15
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

Joined: Oct 28, 2009
Posts: 33
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

Joined: Sep 29, 2008
Posts: 12617

Or better yet, move the definition of what constitutes an "Ace" into the card itself... or even the game (consider wildcards).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calculating values with multiple conditions.
 
Similar Threads
Blackjack program not good with random cards
create a hand of cards
Error
Help With 5 card stud program
Making a simple blackjack game