home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 May / PCWK5A99.ISO / Os2 / WINCARDS.ZIP / SOURCE / wincard.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-19  |  3.0 KB  |  103 lines

  1. #include <bool.h>
  2. #ifndef wincard_h
  3. #define wincard_h
  4.  
  5. class Wincard
  6. {
  7.     enum { namesize = 41 };
  8.  
  9. private:
  10.  
  11.     /*      The name on the card is stored in an array of constant size     */
  12.     /*      The info on the card is stored in an array of variable size     */
  13.     /* The number of characters in the card's data field is an int          */
  14.  
  15.     char index[namesize];
  16.     char * cardinfo;
  17.     int numcardchars;
  18.  
  19. public:
  20.  
  21.     Wincard();
  22.     ~Wincard();
  23.     Wincard(char index[], int numcardchars, char* cardinfo);
  24.     char * showcardinfo() const;
  25.     char * showindexinfo();
  26.     int shownumcardchars() const;
  27.  
  28.     /*                                                                      */
  29.     /*      Assignment operator is necessary due to use of pointers         */
  30.     /*                                                                      */
  31.  
  32.     Wincard & operator = (const Wincard & Fromcard);
  33.  
  34.     /*      Copy constructor also required                                  */
  35.  
  36.     Wincard(const Wincard & Fromcard);
  37.  
  38.     /*      Comparison operators                                            */
  39.  
  40.     bool operator < (const Wincard & Thiscard) const;
  41.     bool operator > (const Wincard & Thiscard) const;
  42.     bool operator < (const char* Indexstring) const;
  43.     bool operator > (const char* Indexstring) const;
  44.     bool operator == (const Wincard & Thiscard) const;
  45.     bool operator == (const char* Indexstring) const;
  46.  
  47.     /*      Use friend function to reverse operands                         */
  48.  
  49.     friend int operator < (const char* Indexstring, const Wincard & Thiscard);
  50.     friend int operator > (const char* Indexstring, const Wincard & Thiscard);
  51.     friend bool operator == (const char* Indexstring, const Wincard & Thiscard);
  52.  
  53. };
  54.  
  55. typedef Wincard Card;
  56.  
  57. class Linkedlist
  58. {
  59.  
  60.     struct Node
  61.     {
  62.         Card onecard;
  63.         struct Node * next;
  64.         struct Node * previous;
  65.     };
  66.  
  67. private:
  68.     Node * firstcard;
  69.     Node * lastcard;
  70.  
  71.     /*      Use the topcard pointer to indicate which card is on top of the stack   */
  72.  
  73.     Node * topcard;
  74.  
  75. public:
  76.     Linkedlist();
  77.     ~Linkedlist();
  78.  
  79.     /*                                                                      */
  80.     /*      Copy constructor -- required                                    */
  81.     /*                                                                      */
  82.  
  83.     Linkedlist (const Linkedlist & Fromlist);
  84.  
  85.     /*                                                                      */
  86.     /*      Assignment operator -- required                                 */
  87.     /*                                                                      */
  88.  
  89.     Linkedlist & operator = (const Linkedlist & Fromlist);
  90.  
  91.     /*      Card handling functions                                         */
  92.  
  93.     int cardcount() const;
  94.     bool getcards (const Card &onecard);
  95.     bool insertcard (const Card &newcard);
  96.     bool delcard ();
  97.     Card showcard (int cardnumber);
  98.     void movecard (int cardnumber);
  99.  
  100. };
  101.  
  102. #endif
  103.