Blackjack Program

jstone3503

New member
Joined
Nov 20, 2006
Messages
3
Programming Experience
1-3
Hey guys. I am having to make a Blackjack program using Visual Basic for my final for my programming class, but I'm having some problems with it and was wondering if somebody could point me in the right direction. Don't worry I'm not cheating, just needing some advice.

Here is what we have to do:
1. Ask for the player's name.
2. Has a deal, hit, stay and quit button.
3. Player starts with $5,000.
4. Player should be able to click hits to get as close to or equal to 21 without going over. The player can only receive a maximum of five cards.
5. Dealer's cards are not shown until the stay button is clicked.
6. If the dealer's card dont total 17 or higher, they must hit until they reach 17 or higher.
7. If both dealer and player have the same total and both are less than or equal to 21, a label will display "Push" or "Win" or "Lose" based on whether the Dealer or Player wins.

OK here's where I need some help. We have not learned arrays yet, so I'm having to use Do While or Do Until Loops.


I have a random generator create two random numbers for the first two cards automatically.

I can't figure out how to do the 17 thing with the dealer. If their total is less than 17, it will create another random number and add that to the total and check to see if its still less than 17 and so forth until it either reaches 17 or the dealer has 5 cards.

Can someone help me figure out how to use the random generator in this loop...that is the toughest part I'm having problems with.

Thanks in advance.
 
Since your using Do While, can't you just say something like,

psuedo-code

do while dealers hand less than 17

deal another card

if dealer has five cards
exit do loop

loop
 
How can you expect to simply use a random number generator? What if you come up with a hand of 5 2's? (Some theory allows that even if its a RND we could get the same number over such a small set). Card decks don't have 5 2's.

Somewhere on the boards here there is another card game thread that has a discussion about setting the deck up as a class (I believe) and taking cards from the 'deck' and into a players 'hand'. You might want to search around a bit for that.

But, on a more serious note, you may need to seek a bit more guidance from your instructor. Foregoing any major typo above it seems like you've been given an asignment that isn't logically completeable (its based on a deck of cards, but dosen't follow the rules of said deck) and, your @ the appearent end of a programming course that didn't cover arrays? Something there needs to be addressed as arrays are fairly basic to VB and .NET.

But, if we can help, do post more, answers will come as they are able!
 
well the only random thing we've learned is the random.next funvtion, even though i know about the rnd function which i could probably get by with. as far as 52 cards, since we haven't learned arrays, we are just basically using one suit and literally not even displaying the cards, just the numbers:

For example, 1 is an Ace and as long as the sum of the cards dont go over 21, it will count as 11. 2-10 are their face value and 10 also is a J,Q,K. SO basically it's just using 1-10. So more of a game of "21" as opposed to Blackjack.
 
It wouldn't be right getting random 1-10, you have to get from range 1-13 and translate to game value afterwards because of the statistical random distribution when you have 4 out of 13 cards with a game value of 10.
 
Back
Top