home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / scase.zip / SCASE.Z / SAMPLE.CC < prev    next >
C/C++ Source or Header  |  1994-10-18  |  725b  |  40 lines

  1. #include "shape.h"
  2. #include "line.h"
  3.  
  4. #define NUMSHAPES 10
  5. void CreateShapes(Shape *Shapes[], int NumShapes);
  6.  
  7. void main()
  8. {
  9.   // Create shapes
  10.   Shape *Shapes[NUMSHAPES];
  11.   CreateShapes(Shapes, NUMSHAPES);
  12.  
  13.   // Draw shapes
  14.   for (int i=0; i<NUMSHAPES; i++)
  15.     Shapes[i]->Draw();
  16.  
  17.   // Delete shapes
  18.   for (i=0; i<NUMSHAPES; i++)
  19.     delete Shapes[i];
  20. }
  21.  
  22. void CreateShapes(Shape *Shapes[], int NumShapes)
  23. {
  24.   for (int i=0; i<NumShapes; i++)
  25.   {
  26.     switch (i%3)
  27.     {
  28.       case 0:
  29.         Shapes[i] = new Line('*', 10);
  30.         break;
  31.       case 1:
  32.         Shapes[i] = new Line('+', 20);
  33.         break;
  34.       case 2:
  35.         Shapes[i] = new Line('x', 30);
  36.         break;
  37.     }
  38.   }
  39. }
  40.