Thread: BlackJack Program...

  1. #1
    Registered User
    Join Date
    Apr 2002

    Angry BlackJack Program...

    I am writing a Blackjack program and am having some trouble with it. I have already created 3 classes (i.e. Card.h, Deck.h, and Hand.h) but I am having trouble pulling them altogether in the Main. Here is what I need to do...

    *Program will be playing single hands against getting to 21 until the deck is empty. Onece the deck is empty, even if it occurs in the middle of playing a hand, the program should end.

    This is what I know so far, but how do I implement it into the main...

    *When starting a new hand, 2 cards are dealt into that hand. I should take 2 cards off the deck using the getNextCard() method and add each card to the hand using the addCard() method.
    *Next I should check to see if the player has a blackjack, outputing a message if they have and then move on to the next hand.
    *Else, I should prompt the user to either hit or stand.
    *If the user stands, then print they "Win" and the next hand should start.
    *If the hit, get another card and add it to the hand.
    *If they exceed 21 then print they "busted" and start next hand.
    *If after hitting, their hand equals 21, then they win. Print a message and start new hand.
    *If hand is still under 21, prompt user again if they want to stand or hit...repeat until they stand, get 21, or bust.

    Main should look something like this...

    #include <iostream>
    #include "Card.h"
    #include "Deck.h"
    #include "Hand.h"

    int main()
    Deck the Deck;
    Hand the Hand;
    //missing code here
    return 0;

    Thanks for the help guys.

  2. #2
    Seņor Member
    Join Date
    Jan 2002
    I don't see why you need 3 classes for a simple blackjack program. I made one in about 200 lines, and my coding wasnt that efficient. 3 classes just makes that program way more confusing than it should be.

  3. #3
    Registered User
    Join Date
    May 2002
    Is their any way for your classes to communicate with eachother, aka friend or inheritance(or is everything public)?. Plus it might help if we could see your header files.

  4. #4
    Registered User
    Join Date
    May 2002
    Not to be a jack.......... or anything, but it is good programming practice to make your code modular. If you always try to program with 'good practice' then it will be natural when you move onto bigger projects. Plus its a good way to practice with classes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. blackjack program
    By mackieinva in forum C Programming
    Replies: 8
    Last Post: 09-20-2007, 03:46 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM