finally

This is a discussion on finally within the C++ Programming forums, part of the General Programming Boards category; got my black jack game working! lvp is found at www.lvp.com...

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

    finally

    got my black jack game working!

    lvp is found at www.lvp.com
    Attached Files Attached Files

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Looks good from what I can tell. Couple of things. First off, you probably shouldn't call randomize() at the beginning of each loop, you'll tend to get bad random numbers that way. Call it at the beginning of the program and never again.

    Second, to make your life easier, consider using arrays to store the values of the different cards, thus getting rid of all of your if statements.
    Instead of this:
    Code:
        if(ran==11)
            {
             display='J';
             cardvalue=10;
            }
    
          if(ran==12)
            {
             display='Q';
             cardvalue=10;
            }
         etc....
    try this:
    Code:
    // declared at top
    char cardnames[13]={'A','1','2','3','4','5','6','7','8','9','0','J','Q','K'};
    int values[13]={1,2,3,4,5,6,7,8,9,10,10,10,10};
    
    // used instead of the if statements
    display=cardnames[ran-1];
    cardvalue=values[ran-1];
    And last you don't have aces being 1 OR 11 depending on which is better. Makes it hard to get a blackjack!
    Last edited by PJYelton; 04-02-2003 at 01:09 PM.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    ya aces are 1 since its my first good console program

    now im learning about the "void" and how it works

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    heres a compiled version of it for download

    http://www.mysticmagma.com/code/blackjack2.exe

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    i found a few little bugs in it when i was working today so i will update those really soon, and i would like to figure out how i can render a card on the screen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finally Graduated
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 06-01-2006, 01:04 AM
  2. Replies: 6
    Last Post: 12-21-2005, 02:49 AM
  3. I finally went to the doctor...
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 07-28-2004, 02:31 PM
  4. I Think I Finally Get It!
    By LordVirusXXP in forum C++ Programming
    Replies: 2
    Last Post: 12-18-2002, 01:43 PM
  5. I finally got...
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 11-18-2001, 06:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21