home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / graph / line.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  2.7 KB  |  78 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. #include <istring.hpp>
  19. #include <math.h>
  20.  
  21.  
  22. class Line : public Graphics
  23. {
  24. public:
  25.  
  26.   double ivXStart;
  27.   double ivYStart;
  28.   double ivXEnd;
  29.   double ivYEnd;
  30.  
  31.  
  32.   Line(int graphicsKey, IString id, double xstart, double ystart,
  33.                                     double xend,   double yend)
  34.  
  35.                                   : Graphics(graphicsKey, id),
  36.                                     ivXStart(xstart),
  37.                                     ivYStart(ystart),
  38.                                     ivXEnd(xend),
  39.                                     ivYEnd(yend)
  40.                                     { }
  41.  
  42.  
  43.   IBoolean operator== (Line const& line) const
  44.     {
  45.      return (this->ivXStart == line.ivXStart &&
  46.              this->ivYStart == line.ivYStart &&
  47.              this->ivXEnd == line.ivXEnd &&
  48.              this->ivYEnd == line.ivYEnd);
  49.     }
  50.  
  51.  
  52.   void           draw() const
  53.     {
  54.      cout << "drawing "
  55.           << Graphics::id()
  56.           << endl
  57.           << "with starting point: "
  58.           << "(" << this->ivXStart
  59.           << "|" << this->ivYStart << ")"
  60.           << " and with ending point: "
  61.           << "(" << this->ivXEnd
  62.           << "|" << this->ivYEnd << ")"
  63.           << endl;
  64.     }
  65.  
  66.  
  67.   void           lengthOfLine() const
  68.     {
  69.      cout << "The length of line "
  70.           << Graphics::id()
  71.           << " is: "
  72.           << sqrt(pow(((this->ivXEnd) - (this->ivXStart)),2)
  73.                 + pow(((this->ivYEnd) - (this->ivYStart)),2))
  74.           << endl;
  75.     }
  76.  
  77. };
  78.