Please Delete
Printable View
Please Delete
I haven't gone through all of your code, but a couple of things leap out at me:
1) Do you ever construct a Deck object? If not, you'll get a NullPointerException whenever you try to use your Deck object.
2) You seem to be trying to use AWT components (i.e., Buttons) in a Swing app (JApplet). This can cause unwanted side effects and should be avoided. Make this a pure Swing app, and only use Swing components (such as JButtons).
3) Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:
Best of luck,Code:[code]
// your code goes here
// notice how the top and bottom tags are different
[/code]
Pete
meeper,
I suggest that (fore now atleast) you should
1. just add a couple of JLabels to your frame.
2. Create a displayHands(); method which sets the text of each JLabel to the string value of the associated hand
3. and add a toString method to your Hand class, which just iterates the values (until null) and appends the value of each card to a StringBuffer.
That's how I tackled it... it works well enough for now.
Later on you can come back and add pictures for the cards, and workout how to lay them out (overlapping) on the screen... but for now I think you should be concentrating on the rules of the game... Blackjack is nice little logic problem.
BTW... I like your addCard method maintains the value... nice.
Cheers. Keith.