Not generating the same card twice?

This is a discussion on Not generating the same card twice? within the C++ Programming forums, part of the General Programming Boards category; OKay s I'm attempting to make a card dealing program right now, then eventually maybe make a War card game ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    106

    Not generating the same card twice?

    OKay s I'm attempting to make a card dealing program right now, then eventually maybe make a War card game then move on to more complicated games... My problem is not generating the same card twice.. I've attempted to store an array "cardCheck" to compare to but when you run my code you will see its not working.. I'm not sure what the problem.
    I've also added some code for use in debugging

    Code:
    #include <iostream>
    #include <vector>
    #include <time.h>
    
    enum cardSuits{
        HEARTS = 0, CLUBS, SPADES, DIAMONDS
    };
    
    enum cardValues{
        TWO = 0, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
    };
    
    class cpuPlayer{
        std::vector <std::string> cpuHand;
        std::vector <int> cpuHandPower;
    
    
    };
    
    class deck{
    
        std::vector <std::string> originalDeck;
        std::vector <int> originalDeckPower;
        std::vector <std::string> shuffledDeck;
        std::vector <int> shuffledDeckPower;
    
    
        public:
        deck();
    
        void fillOriginalDeck();
    
    };
    
    deck::deck(){
        originalDeck.reserve(52);
        originalDeckPower.reserve(52);
        shuffledDeck.reserve(52);
        shuffledDeckPower.reserve(52);
    }
    
    void deck::fillOriginalDeck(){
        originalDeck.clear();
        originalDeckPower.clear();
        bool cardCheck[4][13] = {
                                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                                };
    
    
        for(int b = 0; b < 52; b++){
            std::cout<<"\nB: " << b;
            bool complete = false;
            int suit = rand() % 4;
            int value = rand() % 13;
            std::cout<< "\nSuit:" << suit << "\nValue:" << value;
            do{
                if(cardCheck[suit][value] == 0){
                    complete = true;
                    std::string valueText = "";
                    std::string suitText = "";
                    switch(value){
                        case TWO:
                        originalDeckPower.push_back(TWO);
                        valueText = "Two";
                        break;
    
                        case THREE:
                        originalDeckPower.push_back(THREE);
                        valueText = "Three";
                        break;
    
                        case FOUR:
                        originalDeckPower.push_back(FOUR);
                        valueText = "Four";
                        break;
    
                        case FIVE:
                        originalDeckPower.push_back(FIVE);
                        valueText = "Five";
                        break;
    
                        case SIX:
                        originalDeckPower.push_back(SIX);
                        valueText = "Six";
                        break;
    
                        case SEVEN:
                        originalDeckPower.push_back(SEVEN);
                        valueText = "Seven";
                        break;
    
                        case EIGHT:
                        originalDeckPower.push_back(EIGHT);
                        valueText = "Eight";
                        break;
    
                        case NINE:
                        originalDeckPower.push_back(NINE);
                        valueText = "Nine";
                        break;
    
                        case TEN:
                        originalDeckPower.push_back(TEN);
                        valueText = "Ten";
                        break;
    
                        case JACK:
                        originalDeckPower.push_back(JACK);
                        valueText = "Jack";
                        break;
    
                        case QUEEN:
                        originalDeckPower.push_back(QUEEN);
                        valueText = "Queen";
                        break;
    
                        case KING:
                        originalDeckPower.push_back(KING);
                        valueText = "King";
                        break;
    
                        case ACE:
                        originalDeckPower.push_back(ACE);
                        valueText = "Ace";
                        break;
                    }
    
                    switch(suit){
                        case HEARTS:
                        suitText = "Hearts";
                        break;
    
                        case CLUBS:
                        suitText = "Clubs";
                        break;
    
                        case SPADES:
                        suitText = "Spades";
                        break;
    
                        case DIAMONDS:
                        suitText = "Diamonds";
                        break;
                    }
                    originalDeck.push_back(valueText + " of " + suitText);
    
                }
                else{
                    complete = false;
                }
    
            } while(!complete);
        }
    
    
    
        //this simply prints the deck, could've put it in a new function
        for(int z = 0; z < originalDeck.size(); z++)
        {
        std::cout<<"\n" << originalDeck[z];
        }
        std::cout<<"\nNumber of Cards: "<< originalDeck.size();
    
    }
    
    int main(){
        srand(time(NULL));
        deck deckOne;
        std::cout<<"here we go\n";
        deckOne.fillOriginalDeck();
    }

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    Most people would likely suggest filling the deck sequentially and then using a shuffle algorithm on that deck (std::random_shuffle perhaps) to mix things up. When you wish to draw your cards you then just move through the cards in the deck one-by-one.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    106
    okay.. thanks I thought about doing it that way, this way, a couple other ways, but chose this one because i really didnt think it through

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    87
    It might simply things a bit also if you wrapped your suit and value together in a struct or class. Something like

    Code:
    enum CardValue { ... };
    enum CardSuit { ... };
    
    struct Card {
      CardValue val;
      CardSuit suit;
    
      Card(CardValue v, CardSuit s) : val(v), suit(s) { }
    };
    Then you can construct cards like
    Code:
      vector<Card> deck;
    
      suit = <your generating code here>
      val = <your generating code here>
    
      Card card = Card(val, suit);
      deck.push_back(card);
    Not necessary, but might help keep your code shorter and easier to read, since a Card will have its own concrete data type representation in your program.

    You could go on to to overload operators like "<" so that a comparison like the following would have the correct semantics based on value and suit:
    Code:
    Card card1, card2;
    ...
    if (card1 < card2) {
     ...
    }

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    106
    Thanks for the extra input.. This is how I have it coded right now

    Code:
    #include <iostream>
    #include <vector>
    #include <time.h>
    
    #define NUMBER_OF_CARDS 52
    
    enum CardValues
    {
        TWO = 2, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
    };
    
    class Deck
    {
        int cardDeckValues[NUMBER_OF_CARDS];
        std::string cardDeck[NUMBER_OF_CARDS];
        std::vector <std::string> playersHandValues;
        std::vector <std::string> playersHand;
        std::vector <std::string> cpusHand;
        public:
        Deck();
        void print();
        void shuffle();
        void deal();
    
    };
    
    Deck::Deck()
    {
        cardDeck[0] = "Two of hearts";
        cardDeck[1] = "Two of Diamonds";
        cardDeck[2] = "Two of Clubs";
        cardDeck[3] = "Two of Diamonds";
        cardDeck[4] = "Three of hearts";
        cardDeck[5] = "Three of Diamonds";
        cardDeck[6] = "Three of Clubs";
        cardDeck[7] = "Three of Diamonds";
        cardDeck[8] = "Four of hearts";
        cardDeck[9] = "Four of Diamonds";
        cardDeck[10] = "Four of Clubs";
        cardDeck[11] = "Four of Diamonds";
        cardDeck[12] = "Five of hearts";
        cardDeck[13] = "Five of Diamonds";
        cardDeck[14] = "Five of Clubs";
        cardDeck[15] = "Five of Diamonds";
        cardDeck[16] = "Six of hearts";
        cardDeck[17] = "Six of Diamonds";
        cardDeck[18] = "Six of Clubs";
        cardDeck[19] = "Six of Diamonds";
        cardDeck[20] = "Seven of hearts";
        cardDeck[21] = "Seven of Diamonds";
        cardDeck[22] = "Seven of Clubs";
        cardDeck[23] = "Seven of Diamonds";
        cardDeck[24] = "Eight of hearts";
        cardDeck[25] = "Eight of Diamonds";
        cardDeck[26] = "Eight of Clubs";
        cardDeck[27] = "Eight of Diamonds";
        cardDeck[28] = "Nine of hearts";
        cardDeck[29] = "Nine of Diamonds";
        cardDeck[30] = "Nine of Clubs";
        cardDeck[31] = "Nine of Diamonds";
        cardDeck[32] = "Ten of hearts";
        cardDeck[33] = "Ten of Diamonds";
        cardDeck[34] = "Ten of Clubs";
        cardDeck[35] = "Ten of Diamonds";
        cardDeck[36] = "Jack of hearts";
        cardDeck[37] = "Jack of Diamonds";
        cardDeck[38] = "Jack of Clubs";
        cardDeck[39] = "Jack of Diamonds";
        cardDeck[40] = "Queen of hearts";
        cardDeck[41] = "Queen of Diamonds";
        cardDeck[42] = "Queen of Clubs";
        cardDeck[43] = "Queen of Diamonds";
        cardDeck[44] = "King of hearts";
        cardDeck[45] = "King of Diamonds";
        cardDeck[46] = "King of Clubs";
        cardDeck[47] = "King of Diamonds";
        cardDeck[48] = "Ace of hearts";
        cardDeck[49] = "Ace of Diamonds";
        cardDeck[50] = "Ace of Clubs";
        cardDeck[51] = "Ace of Diamonds";
    
        cardDeckValues[0] = TWO;
        cardDeckValues[1] = TWO;
        cardDeckValues[2] = TWO;
        cardDeckValues[3] = TWO;
        cardDeckValues[4] = THREE;
        cardDeckValues[5] = THREE;
        cardDeckValues[6] = THREE;
        cardDeckValues[7] = THREE;
        cardDeckValues[8] = FOUR;
        cardDeckValues[9] = FOUR;
        cardDeckValues[10] = FOUR;
        cardDeckValues[11] = FOUR;
        cardDeckValues[12] = FIVE;
        cardDeckValues[13] = FIVE;
        cardDeckValues[14] = FIVE;
        cardDeckValues[15] = FIVE;
        cardDeckValues[16] = SIX;
        cardDeckValues[17] = SIX;
        cardDeckValues[18] = SIX;
        cardDeckValues[19] = SIX;
        cardDeckValues[20] = SEVEN;
        cardDeckValues[21] = SEVEN;
        cardDeckValues[22] = SEVEN;
        cardDeckValues[23] = SEVEN;
        cardDeckValues[24] = EIGHT;
        cardDeckValues[25] = EIGHT;
        cardDeckValues[26] = EIGHT;
        cardDeckValues[27] = EIGHT;
        cardDeckValues[28] = NINE;
        cardDeckValues[29] = NINE;
        cardDeckValues[30] = NINE;
        cardDeckValues[31] = NINE;
        cardDeckValues[32] = TEN;
        cardDeckValues[33] = TEN;
        cardDeckValues[34] = TEN;
        cardDeckValues[35] = TEN;
        cardDeckValues[36] = JACK;
        cardDeckValues[37] = JACK;
        cardDeckValues[38] = JACK;
        cardDeckValues[39] = JACK;
        cardDeckValues[40] = QUEEN;
        cardDeckValues[41] = QUEEN;
        cardDeckValues[42] = QUEEN;
        cardDeckValues[43] = QUEEN;
        cardDeckValues[44] = KING;
        cardDeckValues[45] = KING;
        cardDeckValues[46] = KING;
        cardDeckValues[47] = KING;
        cardDeckValues[48] = ACE;
        cardDeckValues[49] = ACE;
        cardDeckValues[50] = ACE;
        cardDeckValues[51] = ACE;
    
    
    
    }
    
    void Deck::shuffle()
    {
        for (int loop; loop < 5000; loop++)
        {
            int randomLocationOne = rand() % 52;
            int randomLocationTwo = rand() % 52;
    
            std::swap(cardDeck[randomLocationOne], cardDeck[randomLocationTwo]);
            std::swap(cardDeckValues[randomLocationOne], cardDeckValues[randomLocationTwo]);
        }
    }
    
    void Deck::print(){
        for (int i; i < NUMBER_OF_CARDS; i++){
            std::cout<< "\n" << cardDeck[i] << " " << cardDeckValues[i];
        }
    }
    void Deck::deal(){
        playersHand.clear();
        cpusHand.clear();
    
        for(int b = NUMBER_OF_CARDS; b > 0; b -= 2){
            playersHand.push_back(cardDeck[1]);
            playersHandValues.push_back(cardDeckValues[1]);
        }
    
    }
    
    
    
    
    int main()
    {
        srand (time(NULL));
        Deck mainDeck;
    
    
    
    }
    Not the easiest way to go about things... I think that the best approach may be creating a card struct(as you showed)... I'm still getting a good feel for all of the OOP stuff right now, still finding little tricks and things... Another question, consider this code here:

    Code:
    class ExampleClass{
    } instance;
    when I code something like this and then try to call the functions I dont get any errors but it doesnt seem to do anything that it's suppost to do, but I can go to where I'm using the class and put ExampleClass instance and everything works correctly.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    106
    So after about and hour or two of a headache with errors I finally got this things figured a little better (I hope)...

    Code:
    #include <vector>
    #include <iostream>
    #include <time.h>
    
    #define NUMBER_OF_CARDS 52
    
    enum CardFace
    {
    	TWO = 0, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
    };
    
    enum CardSuit
    {
        HEARTS = 0, DIAMONDS, SPADES, CLUBS
    };
    
    typedef struct{
    	int myFace;
    	int mySuit;
    
    } Card;
    
    class CardHandler{
    	Card deck[NUMBER_OF_CARDS];
    	public:
    		CardHandler();
    		void shuffle();
    		//void setupDeck();
    		void print();
    };
    
    void CardHandler::shuffle(){
        for(int x; x < 1000; x++)
            std::swap(deck[rand() % 52], deck[rand() % 52]);
    }
    CardHandler::CardHandler(){
        for(int i = 0; i < 13; i++){
            deck[i].mySuit = HEARTS;
        }
        for(int i = 13; i < 26; i++){
            deck[i].mySuit = DIAMONDS;
        }
        for(int i = 26; i < 39; i++){
            deck[i].mySuit = SPADES;
        }
        for(int i = 39; i < 52; i++){
            deck[i].mySuit = CLUBS;
        }
        for(int face = 0; face < 13; face++){
            for(int i = 0; i < 4; i++){
                deck[face].myFace = face;
                deck[face + 13].myFace = face;
                deck[face + 26].myFace = face;
                deck[face + 39].myFace = face;
    
            }
        }
    }
    
    void CardHandler::print()
    {
        for(int i = 0; i < 52; i++){
    
            switch(deck[i].myFace){
                case TWO:
                std::cout<< "\nTwo";
                break;
    
                case THREE:
                std::cout<< "\nThree";
                break;
    
                case FOUR:
                std::cout<< "\nFour";
                break;
    
                case FIVE:
                std::cout<< "\nFive";
                break;
    
                case SIX:
                std::cout<< "\nSix";
                break;
    
                case SEVEN:
                std::cout<< "\nSeven";
                break;
    
                case EIGHT:
                std::cout<< "\nEight";
                break;
    
                case NINE:
                std::cout<< "\nNine";
                break;
    
                case TEN:
                std::cout<< "\nTen";
                break;
    
                case JACK:
                std::cout<< "\nJack";
                break;
    
                case QUEEN:
                std::cout<< "\nQueen";
                break;
    
                case KING:
                std::cout<< "\nKing";
                break;
    
                case ACE:
                std::cout<< "\nAce";
                break;
            }
            std::cout<< " of ";
            switch(deck[i].mySuit){
                case HEARTS:
                std::cout<< "Hearts";
                break;
    
                case DIAMONDS:
                std::cout<< "Diamonds";
                break;
    
                case SPADES:
                std::cout<< "Spades";
                break;
    
                case CLUBS:
                std::cout<< "Clubs";
                break;
            }
        }
    }
    
    
    int main()
    {
    	srand(time(NULL));
    	CardHandler one;
    	one.shuffle();
    	one.print();
    	return 0;
    }

  7. #7
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Quote Originally Posted by jamort View Post
    So after about and hour or two of a headache with errors I finally got this things figured a little better (I hope)...

    Code:
    void CardHandler::shuffle(){
        for(int x; x < 1000; x++)
            std::swap(deck[rand() % 52], deck[rand() % 52]);
    }
    Believe it or not, shuffle code is usually handled sequentially. This reduces the number of swaps you have to do while ensuring that every card has been touched at least once. Something like:
    Code:
    for(int i = 0; i < 51, ++i)
       std::swap(deck[i], deck[i + 1 + rand() % (51 - i));
    Quote Originally Posted by jamort View Post
    Code:
    for(int face = 0; face < 13; face++){
            for(int i = 0; i < 4; i++){
                deck[face].myFace = face;
                deck[face + 13].myFace = face;
                deck[face + 26].myFace = face;
                deck[face + 39].myFace = face;
    
            }
        }
    Note that the inner for loop here does nothing. The value of i is never used. You're just assigning four values four times to the same four places.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    106
    Quote Originally Posted by pianorain View Post
    Believe it or not, shuffle code is usually handled sequentially. This reduces the number of swaps you have to do while ensuring that every card has been touched at least once. Something like:
    Code:
    for(int i = 0; i < 51, ++i)
       std::swap(deck[i], deck[i + 1 + rand() % (51 - i));
    Note that the inner for loop here does nothing. The value of i is never used. You're just assigning four values four times to the same four places.
    okay so... I get what you're saying about the swaps, good point. The for loop I eventually took out reading back through the code I found it. and well here's my code so far that actually allows you to play, only lacking the full code for if the two cards thrown are the same, which I'm probably going to implement later on today.

    Code:
    #include <vector>
    #include <iostream>
    #include <time.h>
    
    #define NUMBER_OF_CARDS 52
    
    enum CardFace
    {
    	TWO = 0, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
    };
    
    enum CardSuit
    {
        HEARTS = 0, DIAMONDS, SPADES, CLUBS
    };
    
    typedef struct
    {
    	int myFace;
    	int mySuit;
    
    } Card;
    
    class CardHandler{
    	Card deck[NUMBER_OF_CARDS];
    	std::vector <Card> playersHand;
    	std::vector <Card> computersHand;
    	public:
    		CardHandler();
    		void shuffle();
    		void deal();
    		void play();
    		void throwCards();
    		int playerReturn();
    		int computerReturn();
    		void checkWin(int, int);
    		void declareWar();
    };
    
    void CardHandler::shuffle()
    {
        for(int i = 0; i < 51; i++ )
            std::swap(deck[i], deck[i + 1 + rand() % (51 - i)]);
    }
    
    CardHandler::CardHandler(){
        for(int i = 0; i < 13; i++)
        {
            deck[i].mySuit = HEARTS;
        }
        for(int i = 13; i < 26; i++)
        {
            deck[i].mySuit = DIAMONDS;
        }
        for(int i = 26; i < 39; i++)
        {
            deck[i].mySuit = SPADES;
        }
        for(int i = 39; i < 52; i++)
        {
            deck[i].mySuit = CLUBS;
        }
        for(int face = 0; face < 13; face++)
        {
            deck[face].myFace = face;
            deck[face + 13].myFace = face;
            deck[face + 26].myFace = face;
            deck[face + 39].myFace = face;
        }
    }
    void CardHandler::deal()
    {
        playersHand.clear();
        computersHand.clear();
        for(int i = 0; i < NUMBER_OF_CARDS; i += 2){
            computersHand.push_back(deck[i]);
            playersHand.push_back(deck[i + 1]);
        }
    }
    
    void CardHandler::play()
    {
        std::cout<< "\nNumber of player cards: " << playersHand.size() << "\n";
        std::cout<< "\nNumber of computer cards: " << computersHand.size() << "\n";
        throwCards();
        std::cin.get();
    }
    
    void CardHandler::throwCards(){
       int playersValue = playerReturn();
       int computersValue = computerReturn();
       checkWin(playersValue, computersValue);
    
    }
    
    int CardHandler::playerReturn(){
    	std::cout<< "\n\nYour card: ";
    	switch(playersHand[0].myFace)
            {
                case TWO:
                std::cout<< "\nTwo";
                break;
    
                case THREE:
                std::cout<< "\nThree";
                break;
    
                case FOUR:
                std::cout<< "\nFour";
                break;
    
                case FIVE:
                std::cout<< "\nFive";
                break;
    
                case SIX:
                std::cout<< "\nSix";
                break;
    
                case SEVEN:
                std::cout<< "\nSeven";
                break;
    
                case EIGHT:
                std::cout<< "\nEight";
                break;
    
                case NINE:
                std::cout<< "\nNine";
                break;
    
                case TEN:
                std::cout<< "\nTen";
                break;
    
                case JACK:
                std::cout<< "\nJack";
                break;
    
                case QUEEN:
                std::cout<< "\nQueen";
                break;
    
                case KING:
                std::cout<< "\nKing";
                break;
    
                case ACE:
                std::cout<< "\nAce";
                break;
            }
            std::cout<< " of ";
            switch(playersHand[0].mySuit)
            {
                case HEARTS:
                std::cout<< "Hearts";
                break;
    
                case DIAMONDS:
                std::cout<< "Diamonds";
                break;
    
                case SPADES:
                std::cout<< "Spades";
                break;
    
                case CLUBS:
                std::cout<< "Clubs";
                break;
            }
    		return playersHand[0].myFace;
    }
    
    int CardHandler::computerReturn(){
    	std::cout<<"\n\nComputer card: ";
    	switch(computersHand[0].myFace)
            {
                case TWO:
                std::cout<< "\nTwo";
                break;
    
                case THREE:
                std::cout<< "\nThree";
                break;
    
                case FOUR:
                std::cout<< "\nFour";
                break;
    
                case FIVE:
                std::cout<< "\nFive";
                break;
    
                case SIX:
                std::cout<< "\nSix";
                break;
    
                case SEVEN:
                std::cout<< "\nSeven";
                break;
    
                case EIGHT:
                std::cout<< "\nEight";
                break;
    
                case NINE:
                std::cout<< "\nNine";
                break;
    
                case TEN:
                std::cout<< "\nTen";
                break;
    
                case JACK:
                std::cout<< "\nJack";
                break;
    
                case QUEEN:
                std::cout<< "\nQueen";
                break;
    
                case KING:
                std::cout<< "\nKing";
                break;
    
                case ACE:
                std::cout<< "\nAce";
                break;
            }
            std::cout<< " of ";
            switch(computersHand[0].mySuit)
            {
                case HEARTS:
                std::cout<< "Hearts";
                break;
    
                case DIAMONDS:
                std::cout<< "Diamonds";
                break;
    
                case SPADES:
                std::cout<< "Spades";
                break;
    
                case CLUBS:
                std::cout<< "Clubs";
                break;
            }
    		return computersHand[0].myFace;
    }
    void CardHandler::checkWin(int playersValue, int computersValue){
        if(playersValue == computersValue){
            declareWar();
        } else if(playersValue < computersValue){
            std::cout<< "\n\nComputer wins\n";
            computersHand.push_back(computersHand[0]);
            computersHand.push_back(playersHand[0]);
        } else if(playersValue > computersValue){
            std::cout<< "\n\nPlayer wins\n";
            playersHand.push_back(computersHand[0]);
            playersHand.push_back(playersHand[0]);
        }
        playersHand.erase(playersHand.begin());
        computersHand.erase(computersHand.begin());
    }
    
    void CardHandler::declareWar(){
        std::cout<< "\n----I----DECLARE----WAR----\n";
    
    
    }
    
    int main()
    {
    	srand(time(NULL));
    	CardHandler one;
    	one.shuffle();
    	one.deal();
    	bool playing = true;
    	do{
    	    one.play();
    	} while(playing);
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 10:06 AM
  2. Bitwise Unwanted Output
    By pobri19 in forum C++ Programming
    Replies: 4
    Last Post: 09-15-2008, 04:07 AM
  3. Vector out of range program crash.
    By Shamino in forum C++ Programming
    Replies: 11
    Last Post: 01-18-2008, 04:37 PM
  4. Segmentation Fault - aaaaaaaah!
    By yogibear in forum C Programming
    Replies: 6
    Last Post: 10-01-2007, 03:21 AM
  5. Blackjack
    By Tommo in forum C Programming
    Replies: 10
    Last Post: 06-20-2007, 08:07 PM

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