< previous page page_1101 next page >

Page 1101
void CardDeck::Recreate( /* inout */ CardPile& pile1,
                         /* inout */ CardPile& pile2 )

// Gathers cards from two piles and puts them back into deck

// Precondition:
//     Length of deck == 0
//  && (Length of pile1 + length of pile2) == DECK_SIZE
// Postcondition:
//     Deck is the list consisting of all cards from pile1@entry
//     followed by all cards from pile2@entry
//  && Length of deck == DECK_SIZE
//  && Length of pile1 == 0  &&  Length of pile2 == 0

{
    CardType tempCard;    // Temporary card

    while (pile1.Length() > 0)
    {
        pile1.RemoveTop(tempCard);
        InsertTop(tempCard);
    }
    while (pile2.Length() > 0)
    {
        pile2.RemoveTop(tempCard);
        InsertTop(tempCard);
    }
}
The Player Object This object manages the playing of the solitaire game. It encapsulates the card deck, on-table pile, and discard pile objects and is responsible for moving cards from one pile to another according to the rules of the game.
To represent the player object, we design a Player class with the following specification:
//******************************************************************
// SPECIFICATION FILE (player.h)
// This file gives the specification of a Player class that manages
// the playing of a solitaire game
//******************************************************************
#ifndef PLAYER_H
#define PLAYER_H

 
< previous page page_1101 next page >