#include #include "deck.h" using namespace std; // This is for convenience // I could use DectT everywhere I use Deck. typedef DeckT Deck; // Pritn the cards in a deck of cards. void PrintDeck(Deck hand) { cout << "This deck has " << hand.Size() << " cards." << endl; while (!hand.IsEmpty() ) { cout << hand.TopCard() << " " ; } cout << endl; return; } int main () { // declare three decks to experiment with. Deck cards, hand1, hand2; int i; // Shuffle uses the random number generator, so initialize it. srand(time(NULL)); // Add some cards to a deck. for(i=1;i<11;i++) { cards.InsertCard(i); } // test the print routine cout << "The Deck" << endl; PrintDeck(cards); cout << endl; // test the suffle routine cout << "The Shuffled Deck " << endl; cards.Shuffle(); PrintDeck(cards); cout << endl; // Test IsEmpty, InsertCard and TopCard while(!cards.IsEmpty()) { hand1.InsertCard(cards.TopCard()); hand2.InsertCard(cards.TopCard()); } cout << "Dealing the Cards " << endl; cout << "Hand 1 " << endl; PrintDeck(hand1); cout << endl; cout << "Hand 2" << endl; PrintDeck(hand2); cout << endl; cout << "The Deck " << endl; PrintDeck(cards); cout << endl; // test adding two decks together. cout << "Merging the Decks " << endl; cards.AddDeck(hand1); cards.AddDeck(hand2); cout << "Hand 1 " << endl; PrintDeck(hand1); cout << endl; cout << "Hand 2" << endl; PrintDeck(hand2); cout << endl; cout << "The Deck " << endl; PrintDeck(cards); cout << endl; // Test MakeEmpty cout << "Throwing away all of the cards " << endl; cards.MakeEmpty(); PrintDeck(cards); cout << endl; // Make sure that TopCard crashes when attempting to remove a card // from an empty deck cout << "The next line should cause the program to crash " << endl; cards.TopCard(); }