How do i make a class to deal a hand????

This is a discussion on How do i make a class to deal a hand???? within the C++ Programming forums, part of the General Programming Boards category; These are my other classes: Code: class Deck { public: // CONSTRUCTION // Default constructor. // Summary : Deck( ); ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    33

    How do i make a class to deal a hand????

    These are my other classes:


    Code:
    class Deck
    {
    
    public:
    
    	// CONSTRUCTION 
    
    	// Default constructor.
    	// Summary  :  
    	Deck(  );
    
    	// Copy Constructor.
    	// Summary  :  
    	Deck( const Deck& from );
    
    	// Destructor.
    	// Summary  :  
    	~Deck( );
    
    	void shuffle(void);
    
    	void printDeck(void);
    
    	// METHODS 
    
    private: 
    
    
    	// METHODS  
    
    
    	// ATTRIBUTES 
    	Card *mDeck[52];
    
    
    };


    Code:
    class Card
    {
    
    public:
    
    	// CONSTRUCTION 
    
    	// Default constructor.
    	// Summary  :  
    	Card();
    	Card( string suit,char pip, int value);
    
    
    	// Copy Constructor.
    	// Summary  :  
    	Card( const Card& from );
    
    	// Destructor.
    	// Summary  :  
    	~Card( );
    
    	// METHODS 
    
    	void setSuit( string suit );
    	string getSuit(void);
    	void setPip(char pip);
    	char getPip(void);
    	void printCard(void);
    
    	//mValue
    	void setValue( int value);
    	int getValue( void);
    
    
    protected: 
    
    
    private: 
    
    
    	// METHODS  
    
    
    	// ATTRIBUTES 
    	string mSuit;
    	char mPip;
    	int mValue;
    
    
    };


    I am trying to deal 5 cards into an array so my other functions can just check the array for the poker hands.




    this is what i attempted....as my constructor


    Code:
    Hand::Hand(Deck)
    {
    	string hand[5];
    	hand[1] = Deck->mDeck[1];
    	hand[2] = Deck->mDeck[2];
    	hand[3] = Deck->mDeck[3];
    	hand[4] = Deck->mDeck[4];
    	hand[5] = Deck->mDeck[5];
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,767
    You have a shuffle method, how about a deal method?

    The deck keeps track of how many cards have been dealt.

    So your hand is
    Code:
    Hand::Hand(Deck) {     
        Card hand[5];
        for ( i = 0 ; i < 5 ; i++ ) 
            hand[i] = Deck->deal(); 
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 07:53 PM
  2. pls fix my deal or no deal program
    By llinocoe in forum C Programming
    Replies: 5
    Last Post: 09-23-2008, 12:37 PM
  3. Replies: 5
    Last Post: 09-18-2008, 03:57 PM
  4. what are some other 'life skills' that can go hand in hand with programming
    By Shadow12345 in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 01-17-2003, 02:34 PM

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