header

class DeckOfCards
{
      
public:
DeckOfCards();
void Shuffle();
void deal();
void hand();
             
private:
int deck[4][13];
int numcard;
int row;
int col;
                     
                     
                     
                     
};

main

#include "dc.h"

using namespace std;
      
      
int main()
{
DeckOfCards DeckCards;

DeckCards.Shuffle();
DeckCards.deal();
DeckCards.hand();
return 0;

}
#include <iostream>
using std::cout;
using std::cin;
using std::right;
using std::left;
using std::endl;

#include <iomanip>
using std::setw;

#include <cstdlib>
using std::srand;
using std::rand;

#include <ctime>
using std::time;

#include "dc.h"

DeckOfCards::DeckOfCards()
{//being constructor
int numcard=0;
//int row=0;
//int col=0;
for (int row=0; row<=3; row++)
{//begin loop
for (int col=0; col<=12; col++)
{//begin inner loop
    deck[row][col]=0;
}//end inner loop
}//end outer loop
srand(time(0));
}//end

void DeckOfCards::Shuffle()
{//start shuffle
     int row;
     int col;
     for (int card=1; card<=52; card++)
     {
         do
         {
              row=rand()%4;
              col=rand()%13;
              }
              while (deck[row][col] !=0 );
              
              deck[row][col] = card;
              }
            //  hand();
              }

  
void DeckOfCards::deal()
{
     static const char *suit[4]={"Hearts" , "Diamonds" , "Clubs", "Spades"};
     
     
static const char *face[13]= {"Ace", "Two", "three", "four", "five", "six", "Seven", 
"Eight", "Nine", "Ten", "Jack", "Queen", "King"};

for (int card=1; card <= 52; card ++)
{
    for (int row=0; row <=3; row++)
    {
        for (int col=0; col <= 12; col ++)
        {
if (deck[row][col]==card)
{
                         
//cout <<setw(5)<< right << face [ col]<<" of " << setw(8) << left << suit[row] << endl;
cout <<setw(5)<< right << face [col]<<" of " << setw(8) << left << suit[row] << endl;



}
                                
}
}

}
                             
     system("PAUSE");    
}//end shuffle
                  
                 
void DeckOfCards::hand()
{

   // cout << card << endl ;
    //  cout << card << endl ;
     
     
     }

How can i make this code deal out, 5 cards?

Create arrays for each hand and put the deck's first card in the first hand/first card, deck's second card in the second hand/first card, etc.

Try to design your classes by looking at real life. Does the deck really shuffle itself? And who deals the hands, who gets the hands?

I see the following objects:
-card
-deck (set of 52 cards)
-hand (set of 5 cards)
-dealer
-player

A final hint: why do you use a platform specific system("PAUSE") if a platform independant cin.get() does the same job?

This article has been dead for over six months. Start a new discussion instead.