home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / NeoIntroTCL3.0 folder / TCL / Laughs / Includes / CPerson.h < prev   
Encoding:
C/C++ Source or Header  |  1994-08-07  |  3.3 KB  |  126 lines  |  [TEXT/KAHL]

  1. /*****
  2.  * CPerson.h
  3.  *
  4.  *    Declaration of application-specific persistent classes.
  5.  *
  6.  *    This sample app is derived from a contribution originally made
  7.  *    by Paul Gee (Thanks Paul!).
  8.  *
  9.  *  Copyright © 1994 NeoLogic Systems.  All rights reserved.
  10.  *
  11.  *****/
  12.  
  13. #include CNeoPartMgrH
  14. #include <string.h>
  15.  
  16. const NeoID kPersonID        = 25;
  17. const NeoID kJokerID         = 26;
  18. const NeoID kClownID        = 27;
  19. const NeoID kJokeID            = 28;
  20. const NeoID kPieID            = 29;
  21.  
  22. const long    kMaxJokeLength    = 80;
  23. const long    kMaxFillingName    = 25;
  24.  
  25. class CPerson : public CNeoPartMgr
  26. {
  27. public:
  28.                         CPerson(const CNeoString &aName = "\p");
  29.     void                getName(CNeoString &aName) const {aName = fName;}
  30.     void                printName(void) const;
  31.     void                setName(const CNeoString &aName = "\p") {fName = aName;}
  32.     virtual void        skill(void) = 0;
  33.  
  34.                         /** I/O Methods **/
  35.     virtual void        readObject(CNeoStream *aStream, const NeoTag aTag);
  36.     virtual void        writeObject(CNeoStream *aStream, const NeoTag aTag);
  37.  
  38. protected:
  39.     CNeoString            fName;
  40. };
  41.  
  42. const long kPersonFileLength    = kNeoPartMgrFileLength + sizeof(CNeoString);
  43.  
  44. class CJoke : public CNeoPersistNative
  45. {
  46. public:
  47.                         CJoke(const char *aText = "");
  48.  
  49.     static CNeoPersist *New(void);
  50.     virtual NeoID        getClassID(void) const;
  51.     virtual long        getFileLength(void) const;
  52.  
  53.                         /** I/O Methods **/
  54.     virtual void        readObject(CNeoStream *aStream, const NeoTag aTag);
  55.     virtual void        writeObject(CNeoStream *aStream, const NeoTag aTag);
  56.  
  57.     void                getJoke(char *aText) const {strncpy(aText, fJoke, kMaxJokeLength -1);}
  58.     void                printJoke(void) const;
  59.     void                setJoke(const char *aText) {strncpy(fJoke, aText, kMaxJokeLength -1);}
  60.  
  61. protected:
  62.     char                fJoke[kMaxJokeLength];
  63. };
  64.  
  65. class CJoker : public CPerson
  66. {
  67. public:
  68.                         CJoker(const CNeoString &aName = "\p");
  69.  
  70.     static CNeoPersist *New(void);
  71.     virtual NeoID        getClassID(void) const;
  72.     virtual long        getFileLength(void) const;
  73.  
  74.     virtual void        skill(void);
  75.     void                forgetJoke(CJoke *aJoke);
  76.     CJoke *                getJoke(const long aIndex);
  77.     long                getJokeCount(void) const {return getListCount();}
  78.     void                learnJoke(CJoke *aJoke);
  79. };
  80.  
  81. class CPie : public CNeoPersistNative
  82. {
  83. public:
  84.                         CPie(const char *aFilling = "Custard");
  85.  
  86.     static CNeoPersist *New(void);
  87.     virtual NeoID        getClassID(void) const;
  88.     virtual long        getFileLength(void) const;
  89.  
  90.                         /** I/O Methods **/
  91.     virtual void        readObject(CNeoStream *aStream, const NeoTag aTag);
  92.     virtual void        writeObject(CNeoStream *aStream, const NeoTag aTag);
  93.  
  94.     void                getFilling(char *aText) const {strncpy(aText, fFilling, kMaxFillingName -1);}
  95.     void                setFilling(const char *aText) {strncpy(fFilling, aText, kMaxFillingName -1);}
  96.  
  97. protected:
  98.     char                fFilling[kMaxFillingName];
  99. };
  100.  
  101. class CClown : public CPerson
  102. {
  103. public:
  104.                         CClown(const CNeoString &aName = "\p", const long aShoeSize = 15);
  105.  
  106.     static CNeoPersist *New(void);
  107.     virtual NeoID        getClassID(void) const;
  108.     virtual long        getFileLength(void) const;
  109.  
  110.                         /** I/O Methods **/
  111.     virtual void        readObject(CNeoStream *aStream, const NeoTag aTag);
  112.     virtual void        writeObject(CNeoStream *aStream, const NeoTag aTag);
  113.  
  114.     CPie *                bakePie(const char *aFilling = "Custard");
  115.     CPie *                getPie(const long aIndex);
  116.     long                getPieCount(void) const {return getListCount();}
  117.     long                getShoeSize(void) const {return fShoeSize;}
  118.     void                setShoeSize(const long aShoeSize) {fShoeSize = aShoeSize;}
  119.     virtual void        skill(void);
  120.     void                throwPie(CPie *aPie);
  121.  
  122. protected:
  123.     long                fShoeSize;
  124. };
  125.  
  126.