Anyone know were i can get some code for this so i can use it edit and fix some rules?
Anyone know were i can get some code for this so i can use it edit and fix some rules?
write it.
trying but i need something to look at to get it right
if by blackjack you mean the game we call pontoon here in the uk then it is very simple to do. At least have a go at it and post what you come up with and we will help more. Nothings free in this world. It doesnt matter too much if you are way off base with your code as long as you show that you are prepared to think about the problem beforehand. Also describe blackjack cos i know about 5 different card games that have all been called blackjack. Most non-graphic card games are quite easy to do when you decide on how to represent the deck.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Black Jack 21
each player is dealt 2 cards (this case just the dealer and player). Then the user can has for a "Hit" they hit untill they want to stop or "Bust".
Bust is when the card total is over 21.
Face Cards are 10
Aces are 1 or 11
yep thats pontoon. its a piece of cake.Try to do it then we can try to fix whatever you come up with. Start by deciding how you will model a deck of cards and then write an algo to shuffle the deck.
Then its just a case of dealing cards and simple counting. have a go. i promise u its not hard to do.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
well i only know so much since im takeing a course in school so it wont be to complex (i hope)
so i figure just something simpe like face cards are 10 and ace is 1.
im gonna need the randomize lib. other than that i dont know were to start
have you learned about arrays yet. you may want to use a 2d array for display and values. you will need to keep counters for the draws, make sure a certain type isn't drawn more than four times. and count how many cards have been given to the player. keep a sum of the values of the deck as well. this is one way of doing it. think it through, it shouldn't be too difficult.
nopeOriginally posted by alpha
have you learned about arrays yet.
well, counters are essential in the program. you could assign some chars J, Q, K, and A for their representative face card. assign some ints to the values, along with the char's corresponding values. randomly choose ints from 1 through 13, and output their value and/or char to the screen. enum data types help if you have learned about those yet.
edit: this is a way of doing it. there are other ways. hope this helps some though.
this is what i have
Code:#include <iostream.h> #include <stdlib.h> #include <conio.h> #include <lvp\random.h> #include <lvp\string.h> int main() { char Answer; char Display; int PlayerValue=0; int DealerValue=0; randomize(); int ran=random(13)+1; int Value; int CardNum; for (CardNum=1; CardNum<=2; CardNum++){ int ran=random(13)+1; if (ran>10){ Value=10; } if (ran==11){ Display='J'; } else if (ran==12){ Display='Q'; } else if (ran==13){ Display='K'; } else { Value=ran; Display=ran+48; } PlayerValue+=Value; cout <<"random " << ran << endl; cout <<"value " << Value << endl; cout << "card value " << Display << endl; cout << endl; cout << "Total: " << PlayerValue << endl; } cout << endl; cout << endl; system("PAUSE"); return 0; }