|
|
|
|
|
|
|
// Additional private members of class (beyond those
// inherited from CardPile):
// voidMerge( CardPile&, CardPile& ); Used by the Shuffle
// function
//******************************************************************
CardDeck::CardDeck()
// Constructor--creates a list of DECK_SIZE components representing
// a standard deck of playing cards
// Postcondition:
// After empty linked list created (via implicit call to base
// class constructor), all DECK_SIZE playing cards have been
// inserted into deck in order by suit and by rank
{
int count; // Loop counter
CardType tempCard; // Temporary card
tempCard.suit = CLUB;
tempCard.rank = 1;
InsertTop(tempCard);
// Loop to create balance of deck
for (count = 2; count <= DECK_SIZE; count++)
{
// Increment rank
tempCard.rank++;
// Test for change of suit
if (tempCard.rank > 13)
{
tempCard.suit = Suits(tempCard.suit + 1);
tempCard.rank = 1;
}
InsertTop(tempCard);
}
}
//****************************************************************** |
|
|
|
|
|