Error Message:
Exception in thread \"main\" java.lang.NumberFormatException: For input string: \"Ace of Clubs\"
at java.lang.NumberFormatException.forInputString
A NumberFormatException
means that Integer.parseInt()
couldn't translate the string into a number.
I would suggest one of two options:
Encapsulate cards as a name(string)/value(int) combo. Use the value to do comparisons, and the name to present info to the user. Cards[]
then becomes a list of cards, not strings.
Parse the strings yourself. Which may be easier, since you've already done it with the if(cards[index].startsWith("Ace")) { value = 1; }
bits. You can move those into a function called CardToInt()
(or whatever), and use that function instead of Integer.parseInt()
.