home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ctdemo.zip / classes / @CLSLIB1.ZIP / cls / icclc / planet.cpp < prev    next >
C/C++ Source or Header  |  1994-12-01  |  2KB  |  138 lines

  1. #ifndef INC_PLANET
  2. #define INC_PLANET
  3.  
  4. #ifndef __FIRST__
  5. #define __FIRST__
  6. #define __IMPL__PLANET
  7. #endif
  8.  
  9. /////V Planet PCM f:\cls_ibm\cls\icclc 1  PM 01.12.94 16:50:21
  10. /*
  11. /////H
  12. 20.10.94 19:37 PM 0 copied from: Planet TOS f:\cls_ibm\cls\icclc 0 PM 19.10.94 00:26:01
  13. 30.03.95 10:34 PM 1 archived: Planet PCM f:\cls_ibm\cls\icclc 1  PM 01.12.94 16:50:21
  14. /////
  15. */
  16.  
  17. /////1
  18. #undef inline
  19.  
  20. #include <bsa.h>
  21.  
  22. /////I isrtset.h @ @ @ @ pre 
  23. #include <isrtset.h>
  24.  
  25. /////I iostream.h @ @ @ @ pre 
  26. #include <iostream.h>
  27.  
  28.  
  29. #ifndef __INLINE__
  30. #define inline
  31. #endif
  32.  
  33. /////C Planet @ @ iccl 
  34. class Planet
  35.  
  36. {
  37.  
  38. private:
  39. /////D bright @  @ instance private 
  40.     float  bright;
  41.  
  42. /////D dist @  @ instance private 
  43.     float  dist;
  44.  
  45. /////D mass @  @ instance private 
  46.     float  mass;
  47.  
  48. /////D plname @  @ instance private 
  49.     char*  plname;
  50.  
  51.  
  52. public:
  53.     inline Boolean operator   < (Planet const&) const;
  54.     inline Boolean operator   == (Planet const&) const;
  55.     inline Boolean  isBright ();
  56.     inline Boolean  isHeavy ();
  57.     inline char*  name ();
  58.     Planet (char*,float,float,float);
  59. };
  60.  
  61.  
  62. /////2
  63. #undef inline
  64.  
  65. /////T IOSup post 
  66. class SayPlanetName : public IIterator<Planet>   {
  67.  public:
  68.    virtual Boolean applyTo(Planet& p)
  69.          { cout << " " << p.name() << " "; return True;}
  70. };
  71. /////
  72.  
  73.  
  74. #if (defined __INLINE__) || (defined __IMPL__PLANET)
  75.  
  76. #ifndef __INLINE__
  77. #define inline
  78. #endif
  79.  
  80. /////F < @ @ const public instance inline 
  81. inline
  82. Boolean Planet:: operator < ( Planet const& aPlanet ) const
  83. {
  84.     return dist < aPlanet.dist;
  85. }
  86.  
  87. /////F == @ @ const public instance inline 
  88. inline
  89. Boolean Planet:: operator == ( Planet const& aPlanet ) const
  90. {
  91.     return plname == aPlanet.plname;
  92. }
  93.  
  94. /////F isBright @ @ public instance inline 
  95. inline
  96. Boolean Planet:: isBright ()
  97.     // bla bla
  98. {
  99.     return (bright < 0.0);
  100. }
  101.  
  102. /////F isHeavy @ @ public instance inline 
  103. inline
  104. Boolean Planet:: isHeavy ()
  105. {
  106.     return (mass   > 1.0);
  107. }
  108.  
  109. /////F name @ @ public instance inline 
  110. inline
  111. char* Planet:: name ()
  112. {
  113.     return  plname;
  114. }
  115.  
  116. /////
  117. #endif
  118.  
  119. /////3
  120. #undef inline
  121.  
  122. #ifdef __IMPL__PLANET
  123. /////F Planet @ @ instance public 
  124. Planet:: Planet ( char* aname, float adist, float amass, float abright )
  125. :
  126.     plname( aname),
  127.     dist( adist),
  128.     mass( amass),
  129.     bright( abright)
  130. {
  131.     ;
  132. }
  133.  
  134. /////
  135. #endif
  136.  
  137. #endif
  138.