Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6.  
  7. class punct
  8. {
  9.     int x, y;
  10.  
  11. public:
  12.     punct();
  13.     punct(int x_t, int y_t)
  14.     {
  15.         x = x_t;
  16.         y = y_t;
  17.     }
  18.     punct operator=(punct z)
  19.     {
  20.         this->x = z.x;
  21.         this->y = z.y;
  22.         return *this;
  23.     }
  24.     vector<int> getter()  ///for point (convert point = vector<int>)
  25.     {
  26.         vector <int> temp;
  27.         temp.push_back(x);
  28.         temp.push_back(y);
  29.         return temp;
  30.     }
  31. };
  32.  
  33.  
  34. class patrat
  35. {
  36.     punct stanga_jos;
  37.     float latura;
  38.  
  39. public:
  40.     patrat();
  41.     patrat(int lungime_temp, punct temp)
  42.     {
  43.         latura = lungime_temp;
  44.         stanga_jos = temp;
  45.     }
  46.     float aria()
  47.     {
  48.         return latura * latura; ///O(1)
  49.     }
  50.     float perimetru()
  51.     {
  52.         return latura * 4; ///merge si la float
  53.     }
  54.     float getter()
  55.     {
  56.         return latura;
  57.     }
  58. };
  59.  
  60. class dreptunghi:protected patrat
  61. {
  62.     float latura2;
  63. public:
  64.     dreptunghi(int latura2_temp, int latura1_temp, punct temp):patrat(latura1_temp, temp), latura2() {}
  65.     float aria()
  66.     {
  67.         return getter()*latura2;
  68.     }
  69.     float perimetru()
  70.     {
  71.         return 2 * (getter() + latura2);  ///static il implementam mai tarziu
  72.     }
  73. };
  74.  
  75.  
  76. class romb:protected patrat
  77. {
  78.     punct punct2;
  79. public:
  80.     romb(punct temp1, int latura1_temp, punct temp):patrat(latura1_temp, temp), punct2() {}
  81.     float perimetru()
  82.     {
  83.         return patrat::perimetru();
  84.     }
  85.     float aria()
  86.     {
  87.         return patrat::aria(); ///idee
  88.     }
  89. };
  90.  
  91.  
  92. class paralelogram:protected dreptunghi, romb
  93. {
  94.  
  95. public:
  96.     paralelogram(int latura1, int latura2,  punct temp1, punct temp2):dreptunghi(latura1, latura2, temp2), romb(temp1, latura2, temp2) {}
  97.     float perimetru()
  98.     {
  99.         return dreptunghi::perimetru();
  100.     }
  101.     float aria()
  102.     {
  103.         return dreptunghi::aria();
  104.     }
  105. };
  106.  
  107. class trapez:protected paralelogram
  108. {
  109.  
  110. public:
  111.     trapez(int latura1, int latura2, punct temp1, punct temp2):paralelogram(latura1, latura2, temp1, temp2) {}
  112.  
  113. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement