loulett

classes

Feb 9th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <cmath>
  3. #include <cstdio>
  4.  
  5. double lenght(int x1, int y1, int x2, int y2)
  6. {
  7.  
  8. }
  9.  
  10. class CShape
  11. {
  12. public:
  13.     CShape();
  14.     ~CShape();
  15.     virtual void Area() = 0;
  16.     virtual void IsPointInside() = 0;
  17. };
  18.  
  19. CShape::CShape()
  20. {
  21. }
  22.  
  23. CShape::~CShape()
  24. {
  25. }
  26.  
  27. class CRect: public CShape
  28. {
  29. public:
  30.     CRect() : CShape() {};
  31.     ~CRect();
  32.     void Area() { printf("%d\n", (right - left) * (bottom - top)); }
  33.     void IsPointInside(int x, int y)
  34.     {
  35.         if (x >= left && x <= right && y >= bottom && y <= top)
  36.             printf("YES\n");
  37.         else
  38.             printf("NO\n");
  39.     }
  40. private:
  41.     int top;
  42.     int left;
  43.     int bottom;
  44.     int right;
  45. };
  46.  
  47. CRect::CRect() : CShape()
  48. {
  49. }
  50.  
  51. CRect::~CRect()
  52. {
  53. }
  54.  
  55. class CCircle: public CShape
  56. {
  57. public:
  58.     CCircle() : CShape() {};
  59.     ~CCircle();
  60.     void Area() { printf("%d\n", rad * rad * M_PI); }
  61.     void IsPointInside(int x, int y)
  62.     {
  63.         double len = length(x, y, xc, yc);
  64.     }
  65.  
  66. private:
  67.     int xc;
  68.     int yc;
  69.     double rad;
  70. };
  71.  
  72. CCircle::CCircle() : CShape()
  73. {
  74. }
  75.  
  76. CCircle::~CCircle()
  77. {
  78. }
  79.  
  80. class CTriangle:public CShape
  81. {
  82. public:
  83.     CTriangle() : CShape() {};
  84.     ~CTriangle();
  85.     void Area() { printf("\n"); }
  86.  
  87. private:
  88.     int x1;
  89.     int y1;
  90.     int x2;
  91.     int y2;
  92.     int x3;
  93.     int y3;
  94. };
  95.  
  96. CTriangle::CTriangle() :CShape()
  97. {
  98. }
  99.  
  100. CTriangle::~CTriangle()
  101. {
  102. }
Advertisement
Add Comment
Please, Sign In to add comment