home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ctdemo.zip / classes / @CLSLIB1.ZIP / cls / icclc / icclctst.cpp next >
C/C++ Source or Header  |  1994-06-17  |  3KB  |  124 lines

  1. #ifndef INCL_ICCLCTST
  2. #define INCL_ICCLCTST
  3.  
  4. #ifndef __FIRST__
  5. #define __FIRST__
  6. #define __IMPL__ICCLCTST
  7. #endif
  8.  
  9. /////V ICCLCTst PCM f:\cls_ibm\cls\icclc 0 PM 20.10.94 19:37:13
  10.  
  11. /*
  12. /////H 
  13. 20.10.94 19:37 PM 0 copied from: ICCLCTst TOS f:\cls_ibm\cls\icclc 0 PM 19.10.94 00:26:01
  14. 30.03.95 10:34 PM 0 archived: ICCLCTst PCM f:\cls_ibm\cls\icclc 0 PM 20.10.94 19:37:13
  15. /////
  16. */
  17.  
  18. /////1
  19. #undef inline
  20.  
  21. #include <bsa.h>
  22.  
  23. /////I Planet @ @ @ @ class pre 
  24. #include <PLANET.CPP>
  25.  
  26. /////I isrtset.h @ @ @ ISortedSet<Planet> @ pre template 
  27. #include <isrtset.h>
  28.  
  29. /////I iostream.h @ @ @ @ pre 
  30. #include <iostream.h>
  31.  
  32. /////I MyUniverse @ @ @ @ class pre 
  33. #include <MYUNIVER.CPP>
  34.  
  35.  
  36. #ifndef __INLINE__
  37. #define inline
  38. #endif
  39.  
  40. /////C ICCLCTst @ @ iccl app 
  41. class ICCLCTst
  42.  
  43. {
  44.  
  45. };
  46.  
  47.     int    main ();
  48.  
  49. /////2
  50. #undef inline
  51.  
  52.  
  53. #if (defined __INLINE__) || (defined __IMPL__ICCLCTST)
  54.  
  55. #ifndef __INLINE__
  56. #define inline
  57. #endif
  58.  
  59. /////
  60. #endif
  61.  
  62. /////3
  63. #undef inline
  64.  
  65. #ifdef __IMPL__ICCLCTST
  66. /////F main @ @ global 
  67. int main()
  68. {
  69.    ISortedSet<Planet>  allPlanets, heavyPlanets, brightPlanets;
  70.  
  71.    ISortedSet<Planet>::Cursor aPCursor(allPlanets);
  72.  
  73.    SayPlanetName showPlanet;
  74.  
  75.    allPlanets.add( Planet("Earth",   149.60f,   1.0000f, 99.9f));
  76.    allPlanets.add( Planet("Jupiter", 778.3f,  317.818f,  -2.4f));
  77.    allPlanets.add( Planet("Mars",    227.9f,    0.1078f, -1.9f));
  78.    allPlanets.add( Planet("Mercury",  57.91f,   0.0558f, -0.2f));
  79.    allPlanets.add( Planet("Neptun", 4498.f,    17.216f,  +7.6f));
  80.    allPlanets.add( Planet("Pluto",  5910.f,     0.18f,  +14.7f));
  81.    allPlanets.add( Planet("Saturn", 1428.f,    95.112f,  +0.8f));
  82.    allPlanets.add( Planet("Uranus", 2872.f,    14.517f,  +5.8f));
  83.    allPlanets.add( Planet("Venus",   108.21f,   0.8148f, -4.1f));
  84.  
  85.    forCursor(aPCursor)    {
  86.       if (allPlanets.elementAt(aPCursor).isHeavy())
  87.          heavyPlanets.add(allPlanets.elementAt(aPCursor));
  88.  
  89.       if (allPlanets.elementAt(aPCursor).isBright())
  90.          brightPlanets.add(allPlanets.elementAt(aPCursor));
  91.     }
  92.  
  93.     cout << "\n\n" << "All Planets: \n";
  94.     allPlanets.allElementsDo(showPlanet);
  95.  
  96.     cout << "\n\n" << "Heavy Planets: \n";
  97.     heavyPlanets.allElementsDo(showPlanet);
  98.  
  99.     cout << "\n\n" << "Bright Planets: \n";
  100.     brightPlanets.allElementsDo(showPlanet);
  101.  
  102.     cout << "\n\n" << "Bright-or-Heavy Planets: \n";
  103.     brightPlanets.unionWith(heavyPlanets);
  104.     brightPlanets.allElementsDo(showPlanet);
  105.  
  106.     cout << "\n\n"
  107.          << "Did you notice that all these Sets are sorted"
  108.          << " in the same order\n"
  109.          << " (distance of planet from sun) ? \n";
  110.  
  111.  
  112.     //************** now let us use an own class that use other generics
  113.     MyUniverse    universe;
  114.     universe.expose();
  115.     universe.exposeReordered();
  116.  
  117.     return 0;
  118. }
  119.  
  120. /////
  121. #endif
  122.  
  123. #endif
  124.