Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help Making a BlackJack Game
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
king202




PostPosted: Wed Apr 21, 2004 1:12 pm   Post subject: Help Making a BlackJack Game

Hey
I need some help making a graphical Blackjack game. If someone can help me out I would be greatful
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Wed Apr 21, 2004 2:37 pm   Post subject: (No subject)

what do you mean by "help"? How are you planning to do it and what exactly have you done so far? We need more information in order to "help" you. And if on the off chance you mean "do this for me" when you say "help" you won't get it.

So tell us what you need help with, and we will surely provide.
king202




PostPosted: Wed Apr 21, 2004 2:55 pm   Post subject: (No subject)

OK I have a Blackjack game That just plays the game blackjack. I was woundering if you could help me make the bet part of it.
I can seem to be able to place a bet and have the money either take away or addon to the total amount.
can you help
Dan




PostPosted: Wed Apr 21, 2004 5:18 pm   Post subject: (No subject)

well u just have a var that holdes how much money they curenly have, then u get input from the users about how much money they whont to bet. if it is more then what they have or an invaled number u ask the qeustion intill they put in vaild input. then once the game is done u add or take away money from the 1st money var deponding on the value of the input of how much to bet. so if they start with 1000:

var money:int:=1000
vet bet:int

put "put in $ to bet"
get bet

%put some error checking here
%put game here


%if they lose the game:
money := money - bet

%else if they win the game

money := money + bet
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
gamer




PostPosted: Wed Apr 21, 2004 5:30 pm   Post subject: (No subject)

if u want u may wish to post wut ur program is so far, then we can hav more understanding of ur game
king202




PostPosted: Wed Apr 21, 2004 9:54 pm   Post subject: (No subject)

Ok here is my program can you please help me Set you the bet part

% BlackJack

var card : int
var input : string
var plays : string
var total : int
var dealer : int
var dcard : int

loop
total := Rand.Int (1, 10)
loop
put total :2
put "would you like to Hit or Stay? <H/S> "..
get input
if input = "H" or input = "h" then
card := Rand.Int (1, 10)
else
exit
end if
total := card + total
exit when total > 21
end loop
loop
dealer := Rand.Int (1, 11)
if dealer < 16 then
dcard := Rand.Int (1, 11)
dealer := dealer + dcard
end if
exit when dealer >= 16
end loop
put "The dealer has "
delay (500)
put dealer, "!"
put "You have "
delay (500)
put total, "!"
if total > 21 and dealer > 21 then
put "You and the dealer busted!"
elsif total > 21 then
put "You busted, dealer wins!"
elsif total = dealer then
put "You and the dealer tied!"
elsif total > dealer then
put "You win!"
elsif dealer > 21 then
put "The dealer busted, you win!"
else
put "The dealer wins!"
end if
end loop
gamer




PostPosted: Wed Apr 21, 2004 10:09 pm   Post subject: (No subject)

is this wut ya want?
code:
% BlackJack

var card, total, dealer, dcard, bet, money : int
var input, plays : string
money := 1000

loop
    total := Rand.Int (1, 10)
    put "You have $", money, "."
    loop
        put "How much would you like to bet for this game? $" ..
        get bet
        exit when bet > 0 or bet <= money  %%%%so the user can only wutever he has
    end loop
    loop
        put total : 2
        put "would you like to Hit or Stay? <H/S> " ..
        get input
        if input = "H" or input = "h" then
            card := Rand.Int (1, 10)
        else
            exit
        end if
        total := card + total
        exit when total > 21
    end loop
    loop
        dealer := Rand.Int (1, 11)
        if dealer < 16 then
            dcard := Rand.Int (1, 11)
            dealer := dealer + dcard
        end if
        exit when dealer >= 16
    end loop
    put "The dealer has "
    delay (500)
    put dealer, "!"
    put "You have "
    delay (500)
    put total, "!"
    if total > 21 and dealer > 21 then
        put "You and the dealer busted!"
        money -= bet
    elsif total > 21 then
        put "You busted, dealer wins!"
        money -= bet
    elsif total = dealer then
        put "You and the dealer tied!"
    elsif total > dealer then
        put "You win!"
    elsif dealer > 21 then
        put "The dealer busted, you win!"
        money += bet
    else
        put "The dealer wins!"
        money -= bet
    end if
    exit when money <= 0
end loop
[/code]
king202




PostPosted: Thu Apr 22, 2004 6:57 am   Post subject: (No subject)

That is Great man Thanks. I have just a couple more question if someone could help.
First Can you explain what you did with the program?
Second How to you assign a king queen jack and ace
thanks alot
AsianSensation




PostPosted: Thu Apr 22, 2004 7:31 am   Post subject: (No subject)

I'm assuming you need this for the graphical part. When you did the Rand.Int (1, 10), you are essentially getting a random card from Ace to 10. Now for the Jack, Queen, and King, just assign each the value of 11, 12, and 13. So Rand.Int (1, 13) would get a random card between Ace and King.

Now, using Rand.Int would not essentially be good for a complex blackjack game, like the real blackjack with every single rules. The best way of handling a blackjack game is to do string manipulation. Such that your "deck" is a long string, and you are cutting and appending on the string, "shuffling" the deck by rearranging substrings. It is a bit more complex, but it's easier to work if you want to implement every rules.
king202




PostPosted: Thu Apr 22, 2004 9:25 am   Post subject: (No subject)

ok so If i want to do this right at the top would i do
jack:=11
queen:=12
king:=13
How would i put these values into the Rand.Int
Delta




PostPosted: Thu Apr 22, 2004 9:39 am   Post subject: (No subject)

Boom! its in a Randint Smile lol I'm not sure what you mean and if it is... ummm...well... ya... good luck with programming.

code:
Rand.Int (1, 13)
Flashkicks




PostPosted: Thu Apr 22, 2004 9:41 am   Post subject: (No subject)

Shocked EeEeEeK.. Lets hope that wasnt too harsh my friend..lol.. But yeah.. Your problem should be fixed.. Confused Confused Confused [Delta's heartLess]
king202




PostPosted: Thu Apr 22, 2004 10:04 am   Post subject: (No subject)

Great Thanks
But i would like it to display King Queen Jack or ace. How would you get it to do that
Delta




PostPosted: Thu Apr 22, 2004 2:00 pm   Post subject: (No subject)

ok.... try something like this...


code:
if card = 11 then
    put "Jack"
elsif card = 12 then
    put "Queen"
elsif card = 13 then
    put "King"
end if
king202




PostPosted: Thu Apr 22, 2004 3:26 pm   Post subject: (No subject)

where would i put that in the code at the top middle or end
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: