//******************************************************************
// SPECIFICATION FILE (cardpile.h)
// This file gives the specifications of
// 1. CardType--a data type representing an ordinary playing card
// 2. CardPile--an unsorted list ADT representing a pile
// of playing cards
//******************************************************************
#ifndef CARDPILE_H
#define CARDPILE_H
enum Suits {CLUB, DIAMOND, HEART, SPADE};
struct CardType
{
Suits suit;
int rank; // Range 1 (ace) through 13 (king)
};
struct NodeType; // Forward declaration (Complete declaration
// is hidden in implementation file)
class CardPile
{
public:
int Length() const;
// Postcondition:
// Function value == number of cards in pile
CardType CardAt( /* in */ int n ) const;
// Precondition:
// n >= 1 && n <= Length()
// Postcondition:
// Function value == card at position n in pile
void InsertTop( /* in */ CardType newCard );
// Precondition:
// newCard is assigned
// Postcondition:
// newCard is at top of pile
void RemoveTop( /* out */ CardType& topCard );
// Precondition:
// Length() > 0
// Postcondition:
// topCard == value of first component in pile at entry
// && topCard is no longer in pile
CardPile();
// Postcondition:
// Empty pile is created
CardPile( const CardPile& otherPile );
// Postcondition:
// Pile is created as a duplicate of otherPile
~CardPile();
// Postcondition:
// Pile is destroyed
private:
NodeType* head;
int listLength;
};
#endif