Trying to make a deck of cards.

This is a discussion on Trying to make a deck of cards. within the C++ Programming forums, part of the General Programming Boards category; My deck has a private member variable with 52 values in it. I have another classes called card that has ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    36

    Trying to make a deck of cards.

    My deck has a private member variable with 52 values in it. I have another classes called card that has a rank, for Ace - King, and a suit for C/S/H/D and I'm trying to read this into the array but I do not know how to access the enumerated types of Rank and Suit though the for loop I provided. Any help?

    Code:
    cDeck::cDeck()
    {
    	int deckNumber = 0;
    	for ( int j = 0; j < 4; j++)
    	{
    		for( int i = 0; i < 13; i++)
    		{
    			m_deck[deckNumber].SetRank(cCard::Rank::[i]);
    			m_deck[deckNumber].SetSuit(cCard::Suit::Clubs);
    			deckNumber++;
    		}
    	}
    
    }

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2,017
    Likely:
    Code:
    m_deck[deckNumber].SetRank(i);
    m_deck[deckNumber].SetSuit(j);
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 11-05-2009, 10:06 PM
  2. Shuffling a deck?
    By Neo1 in forum C++ Programming
    Replies: 23
    Last Post: 07-16-2007, 01:21 AM
  3. Deck Shuffle
    By pjharris in forum C++ Programming
    Replies: 51
    Last Post: 01-06-2006, 03:59 PM
  4. Problem with deck class.
    By SlyMaelstrom in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2005, 05:00 PM
  5. filling a deck of cards
    By lakai02 in forum C Programming
    Replies: 6
    Last Post: 12-07-2002, 09:13 AM

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