Thread: Console Black Jack game

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    41

    Console Black Jack game

    Anyone know were i can get some code for this so i can use it edit and fix some rules?

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    write it.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    trying but i need something to look at to get it right

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    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

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    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

  6. #6
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    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

  7. #7
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    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

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    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.

  9. #9
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    Originally posted by alpha
    have you learned about arrays yet.
    nope

  10. #10
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    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.

  11. #11
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    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;
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D Game project requires extra C++ programmers, new or experienced
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 05-16-2007, 10:46 AM
  2. Help with Black Jack Game
    By Frantic- in forum C++ Programming
    Replies: 5
    Last Post: 02-03-2005, 09:16 PM
  3. console game
    By Prophet-ex in forum Game Programming
    Replies: 7
    Last Post: 01-04-2005, 09:41 AM
  4. I need some ideas please>>
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 08-23-2002, 01:55 PM
  5. Changing the Console text back to black
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 07-12-2002, 08:11 AM