Archived

This topic is now archived and is closed to further replies.

hellllllllllllllllp

This topic is 4947 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im trying to make a console blackjack game and i didnt want to ask for help but i keep hitting a snag. i want to make it so hit is a variable but i dont know how to make the "or" statement. i tried | and || but they didnt work, heres what my code looks like(done in microsoft visual c++.net) // blackjack // its blackjack duh... #include "stdafx.h" #include <iostream> using namespace std; void main() { int ace=1|11; int king= 10; int queen= 10; int jack= 10; int nine= 9; int eight= 8; int seven= 7; int six= 6; int five= 5; int four= 4; int three= 3; int two= 2; int hit= two|three|four|five|six|seven|eight|nine|jack|queen|king|ace; int hand= 0 + hit; int dhand= 0 + hit; cout << "let''s play some black jack" << endl; while(dhand=0) + hit,+ hit; while(hand=0) + hit,+ hit; cout << hand << endl; cout << "want a hit??:y or n..." << endl; char replie; cin >> replie; { if (replie=''y'') hit + hand; if (replie=''n'') cout << "ok, lets see then" << endl; } cout << hand << endl; if (dhand < 15) hit + dhand; cout << dhand << endl; if(hand > 21) cout << "bust!!" << endl; if (hand > dhand) cout << "you win!!!!!!" << endl; if (dhand > hand) cout << "awwwwww to bad, you lose!!...punk" << endl; } ...Also is there a way i can make it so the dealer (dhand) chooses to take a hit without having it a set number...im saying like can i make it so it doesnt just pick when its at less the 15????

Share this post


Link to post
Share on other sites
possible homework alert.....
making a test based blackjack game was a programming assignment when I was in university.

"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA

Share this post


Link to post
Share on other sites
Ok dude, this program has some serious errors, I dont think you understand the language at all. Im trying not to sound to pesimistic, but i recomend you read a book on the langauage.

Ill give you some pointers:
"while(dhand=0)" assigns 0 to dhand, and then since dhand equals zero, ie false, the loop will terminate straight away.

second, and this is a big error:

"int ace=1|11;" assigns 1|11 to ace. now in binary:

1 is 0001
11 is 1011
1|11 is 1011 ie 11. It DOES NOT choose between 1 or 11.

That applies to
"int hit= two|three|four|five|six|seven|eight|nine|jack|queen|king|ace;
" aswell.

You need to think about an arraylist and a random number generator to pick from that list.

"{
if (replie=''y'')
hit + hand;

if (replie=''n'')
cout << "ok, lets see then" << endl;
}"
You dont need random curly brackets in the middle of nowhere.

As for
"...Also is there a way i can make it so the dealer (dhand) chooses to take a hit without having it a set number...im saying like can i make it so it doesnt just pick when its at less the 15???? "
tell us more what you are thinking of.

Sorry to shatter your dreams but this is no where near working.

Yratelev

Share this post


Link to post
Share on other sites
Your program is all whacked out.

Try writing it in Basic or Python or something, you are bitwise oring 1 and 11, two .. aren''t even defined, you are doing weird ass things that make no sense, in effect, what you have written there is gibberish.

Share this post


Link to post
Share on other sites
Id like to help but I can''t see what your code is doing. Maybe you should repost with code comments so we get a better idea of what you are trying to do.

also:

int hit= two|three|four|five|six|seven|eight|nine|jack|queen|king|ace;


simply doesn''t work. In this case you are combining all the cards values into the one variable. If your intention was to
initialize the hit variable you should try using a random statement with an if block or switch statement.

eg

int r = rand() % 12;
switch( r )
{
case 1:
hit = ace;
break;
etc
etc
etc

Hope that helps.

Share this post


Link to post
Share on other sites