Blackjack- buttons and if statements

juggernot

Well-known member
Joined
Sep 28, 2006
Messages
173
Programming Experience
Beginner
I'm creating a blackjack program, and have hit a small snag. When the player presses the next card button, I'll use random numbers between 1 and 10, which will be the value of the card. Once the value is decided I'll show the picture of the appropriate card. For one value their is a few appropriate cards, so I'll find a way to make it pick between them. The only problem is I need to do the same thing to the next picture box the next time he presses the same button. Can someone help me out with that?
 
Try this

Heres what I would do. Create an array for the hand itself, lets call it
hand(8). Then created two arrays for the cards IE: cardvalue(10) and cardcheck(10). When the user is draws the first card, it's value (found in cardvalue(random number) its value is placed into hand(1st card) and a value of "true" is palced into cardcheck(same value as cardvalue). Then when the next card is drawn, if cardvalue(newcard) = false then keep it, else draw another. I use a similar method in a poker program I am working on.
 
I never really got that to work, getting it so that I couldn't pick the same card twice. To be fair, I have not really looked at it. I've been really busy, and for some reason I started another program before finishing that one. I should go back and finish it, but I think that will only happen after I'm done my login program. Which doesn't really make more sense, because the log in program is more advanced.
 
the DrawCard method showed how to pick a random card and remove it from the collection.
 
The way I approached this game is by creating 3 classes for the cards:

Card
Deck
Hand

The card class contains the information for 1 card. The deck is an array of 52 Card objects. This class also implements a shuffle() method. The hand has an arraylist member that is added to when a player hits.

If you would like more detail, ask and I will show.

SD
 
Back
Top