home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Prog_objet / figure.h < prev    next >
C/C++ Source or Header  |  1998-11-09  |  912b  |  45 lines

  1.  
  2. class Figure {
  3. public:
  4.   Figure(float x=0 , float y=0) : _x(x), _y(y) {}
  5.   float getX() const { return _x; }
  6.   float getY() const { return _y; }
  7.   void translate(float dx, float dy);
  8.   virtual float surface() const = 0;
  9. private:
  10.   float _x,_y;
  11. };
  12.  
  13. class Rectangle : public Figure {
  14. public:
  15.   Rectangle(float c1, float c2, float x=0, float y=0) 
  16.     : Figure(x,y), _c1(c1), _c2(c2) {}
  17.   
  18.   float getC1() const { return _c1; }
  19.   float getC2() const { return _c2; }
  20.  
  21.   void setC1(float c1) { _c1 = c1; }
  22.   void setC2(float c2) { _c2 = c2; }
  23.  
  24.   /* virtual */ float surface() const;
  25. private:
  26.   float _c1,_c2;
  27. };
  28.  
  29. class Cercle : public Figure {
  30. public:
  31.   Cercle(float r, float x=0, float y=0) 
  32.     : Figure(x,y) , _r(r) {}
  33.   
  34.   float getRadius() const { return _r; }
  35.   void setRadius(float r) { _r = r; }
  36.  
  37.   /* virtual */ float surface() const;
  38. private:
  39.   float _r;
  40. };
  41.  
  42.  
  43.  
  44.  
  45.