|
|
|
|
|
|
|
enum Suits {CLUB, DIAMOND, HEART, SPADE};
struct CardType
{
Suits suit;
int rank; // Range 1 (ace) through 13 (king)
}; |
|
|
|
|
|
|
|
|
Below is the specification file cardpile.h, which provides the client with declarations for the CardType type and the CardPile class. |
|
|
|
|
|
|
|
|
//******************************************************************
// SPECIFICATION FILE (cardpile.h)
// This file gives the specifications of
// 1. CardType--a data type representing an ordinary playing card
// 2. CardPile--an unordered list ADT representing a pile
// of playing cards
//******************************************************************
#ifndefCARDPILE_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 CarPile
{
public:
int Length() const;
// Postcondition:
// Function value == number of cards in pile
CardType CardAt( /* in */ int n ) const;
// Precondition:
// n >= 1 && n <= length of card pile
// Postcondition:
// Function value == card at position n in pile |
|
|
|
|
|