home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 3.ddi / BGICLA.ZIP / POINT.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-24  |  2.0 KB  |  65 lines

  1. /**************************************************************************
  2.     Listing 3 - POINT.HPP
  3.  
  4.     Written by Kevin D. Weeks, April 1990
  5.     Released to the Public Domain
  6. */
  7.  
  8. #if !defined(POINT_HPP)
  9. #define POINT_HPP      1
  10.  
  11. enum Bool {FALSE, TRUE};
  12.  
  13. class Point
  14. {
  15.   public:
  16. // Constructors.
  17.     // Note: the compliler's "copy constructor" should work just fine so
  18.     // none is provided. No destructor is declared since no cleanup is
  19.     // neccessary
  20.     Point(void);
  21.     Point(const Point *source);
  22.     Point(const int init_x, const int init_y);
  23.     Point(const double init_x, const double init_y);
  24.  
  25. // Get attribute methods.
  26.     int     get_x(void)
  27.             { return x; };
  28.     double  get_virtual_x(void)
  29.             { return virtual_x; };
  30.     int     get_y(void)
  31.             { return y; };
  32.     double  get_virtual_y(void)
  33.             { return virtual_y; };
  34.  
  35. // Set attribute methods.
  36.     void    set_x(const int new_x);
  37.     void    set_x(const double new_x);
  38.     void    set_y(const int new_y);
  39.     void    set_y(const double new_y);
  40.     void    set_xy(const int new_x, const int new_y);
  41.     void    set_xy(const double new_x, const double new_y);
  42.  
  43. // Operators.
  44.     Point   &operator+=(Point &addend);
  45.     Point   &operator-=(Point &subtrahend);
  46.     Bool    operator==(Point &comparator);
  47.     Bool    operator>(Point &comparator);
  48.     Bool    operator<(Point &comparator);
  49.     Bool    operator>=(Point &comparator);
  50.     Bool    operator<=(Point &comparator);
  51.  
  52.   private:
  53.     double          virtual_x;              // virtual world co-ordinate
  54.     double          virtual_y;              // virtual world co-ordinate
  55.     int             x;                      // real world co-ordinate
  56.     int             y;                      // real world co-ordinate
  57.  
  58.     // these are declared and implemented as "friend" methods so that they
  59.     // will work as binary operators.
  60.     friend Point    &operator+(Point &augend, Point &addend);
  61.     friend Point    &operator-(Point &minuend, Point &subtrahend);
  62. };
  63.  
  64. #endif
  65.