< previous page page_1097 next page >

Page 1097
We call the Merge function with two parameters: the shorter list and the longer list.
WHILE more cards in shorterList
  shorterList.RemoveTop(tempCard)
  InsertTop(tempCard)             // Insert into deck
  longerList.RemoveTop(tempCard)
  InsertTop(tempCard)
WHILE more cards in longerList
  longerList.RemoveTop(tempCard)
  InsertTop(tempCard)

Recreate (Inout: pile1, pile2)
The Recreate function takes an empty deck (an empty list) and gathers cards from two piles, putting them back into the deck.
WHILE more cards in pile1
  pile1.RemoveTop(tempCard)
  InsertTop(tempCard)           // Insert into deck
WHILE more cards in pile2
  pile2.RemoveTop(tempCard)
  Deck.InsertTop(tempCard)

Below is the implementation file for the CardDeck member functions.
//******************************************************************
// IMPLEMENTATION FILE (carddeck.cpp)
// This file implements the CardDeck class member functions.
// The CardPile class is a public base class of CardDeck
//******************************************************************
#include carddeck.h
#include <stdlib.h>     // For rand()

const int HALF_DECK = 26;

 
< previous page page_1097 next page >