home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / planets / planet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  2.5 KB  |  63 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. /*-------------------------------------------------------------*\
  19. |  planet.h  -  Class Planet for use in our Sorted Set example  |
  20. \*-------------------------------------------------------------*/
  21. #include <iostream.h>
  22. #include <iappl.h>
  23.  
  24. class Planet   {
  25.  private:
  26.    char* plname;
  27.    float dist;
  28.    float mass;
  29.    float bright;
  30.  
  31.  public:
  32.      // Let's use the compiler generated default for
  33.      // the copy constructor
  34.  
  35.    Planet(char* aname, float adist, float amass, float abright) :
  36.      plname(aname), dist(adist),  mass(amass), bright(abright) {}
  37.  
  38.      // For any Set we need to provide element equality.
  39.    IBoolean operator== (Planet const& aPlanet) const
  40.       { return plname == aPlanet.plname; }
  41.  
  42.      // For a Sorted Set we need to provide element comparision.
  43.    IBoolean operator< (Planet const& aPlanet) const
  44.       { return dist < aPlanet.dist; }
  45.  
  46.    char*   name()     { return  plname; }
  47.  
  48.    IBoolean isHeavy()  { return (mass   > 1.0); }
  49.    IBoolean isBright() { return (bright < 0.0); }
  50. };
  51.  
  52.  
  53. /*-------------------------------------------------------------*\
  54. |   Applicator                                                  |
  55. \*-------------------------------------------------------------*/
  56.  
  57. class SayPlanetName : public IApplicator<Planet>   {
  58.  public:
  59.    virtual IBoolean applyTo(Planet& p)
  60.          { cout << " " << p.name() << " "; return True;}
  61. };
  62.  
  63.