• Post Reply Bookmark Topic Watch Topic
  • New Topic

incrementing variable problem  RSS feed

 
Sam Hackett
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://pastebin.com/ZNrY57gE

I like what I have in total, but I tried to include just the code relevant to my problem below. So, basically, it's a blackjack gui. I assign the current card, in the form "two" for example, to the String playerCardsInHand on line 8. playerCardsInHand is passed to the method playerTotal where I search the array faces for the String value and then increment the total. But I can't figure out why the total gets screwed up. When 8 should be added for the String "eight", 128 is added instead. 124 instead of 4. Any help is appreciated. It's driving me crazy.


 
Paweł Baczyński
Bartender
Posts: 2074
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

First of all, StringsAreBad. you should be using an enum.

Your problem is an else statement on lines 37-38. It always adds 10 if a card name doesn't equal to faces[i].
 
Sam Hackett
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!