home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / EXAMPLES.ZIP / FIGURES.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  1.4 KB  |  53 lines

  1. // figures.h contains three classes.
  2. //
  3. //  Class Location describes screen locations in X and Y
  4. //  coordinates.
  5. //
  6. //  Class Point describes whether a point is hidden or visible.
  7. //
  8. //  Class Circle describes the radius of a circle around a point.
  9. //
  10. // To use this module, put #include <figures.h> in your main
  11. // source file and compile the source file FIGURES.CPP together
  12. // with your main source file.
  13.  
  14. enum Boolean {false, true};
  15.  
  16. class Location {
  17. protected:
  18.    int X;
  19.    int Y;
  20. public:
  21.    Location(int InitX, int InitY) {X = InitX; Y = InitY;}
  22.    int GetX() {return X;}
  23.    int GetY() {return Y;}
  24. };
  25.  
  26. class Point : public Location {
  27. protected:
  28.    Boolean Visible;
  29. public:
  30.    Point(int InitX, int InitY);
  31.    virtual void Show();       // Show and Hide are virtual
  32.    virtual void Hide();
  33.    virtual void Drag(int DragBy); // new virtual drag function
  34.    Boolean IsVisible() {return Visible;}
  35.    void MoveTo(int NewX, int NewY);
  36. };
  37.  
  38. class Circle : public Point {  // Derived from class Point and
  39.                                // ultimately from class Location
  40. protected:
  41.    int Radius;
  42. public:
  43.    Circle(int InitX, int InitY, int InitRadius);
  44.    void Show();
  45.    void Hide();
  46.    void Expand(int ExpandBy);
  47.    void Contract(int ContractBy);
  48. };
  49.  
  50. // prototype of general-purpose, non-member function
  51. // defined in FIGURES.CPP
  52.  
  53. Boolean GetDelta(int& DeltaX, int& DeltaY);