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?