Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace::std;
  4. const double pi = 3.14;
  5.  
  6. class Kolo
  7. {
  8. private:
  9. double pole;
  10. double obwod;
  11. double promien;
  12. int wspolrzedne[2];
  13.  
  14. public:
  15.  
  16.  
  17. Kolo()
  18. {
  19. promien = 2;
  20. wspolrzedne[0] = 0;
  21. wspolrzedne[1] = 0;
  22. pole = pi * promien * promien;
  23. obwod = 2 * pi * promien;
  24. }
  25.  
  26. Kolo(double promien, int x, int y)
  27. {
  28. this->promien = promien;
  29. this->wspolrzedne[0] = x;
  30. this->wspolrzedne[1] = y;
  31. this->pole = pi * promien * promien;
  32. this->obwod = 2 * pi * promien;
  33. }
  34.  
  35. ~Kolo()
  36. {
  37.  
  38. }
  39.  
  40. void podajPole()
  41. {
  42. cout << "Pole kola = " << this->pole << endl;
  43. }
  44.  
  45. void wypisz()
  46. {
  47. cout << "X = " << this->wspolrzedne[0] << ", Y = " << this->wspolrzedne[1] << endl;
  48. }
  49.  
  50. Kolo operator +(Kolo & temp)
  51. {
  52. this->pole += temp.pole;
  53. return *this;
  54. }
  55.  
  56. Kolo operator -(Kolo & temp)
  57. {
  58. this->pole -= temp.pole;
  59. return *this;
  60. }
  61.  
  62. Kolo operator /(Kolo& temp)
  63. {
  64. this->pole /= temp.pole;
  65. this->pole = sqrt(this->pole);
  66. return * this;
  67. }
  68.  
  69. bool operator >(Kolo& temp)
  70. {
  71. if (this->pole > temp.pole)
  72. {
  73. return true;
  74. }
  75. else
  76. {
  77. return false;
  78. }
  79. }
  80.  
  81. bool operator <(Kolo& temp)
  82. {
  83. if (this->obwod > temp.obwod)
  84. {
  85. return true;
  86. }
  87. else
  88. {
  89. return false;
  90. }
  91. }
  92.  
  93.  
  94. };
  95.  
  96. int main()
  97. {
  98. Kolo temp1;
  99. Kolo temp2;
  100. Kolo temp3(5, 1, 1);
  101.  
  102. temp1.podajPole();
  103. temp2.podajPole();
  104. temp3.podajPole();
  105.  
  106. temp1.wypisz();
  107. temp2.wypisz();
  108. temp3.wypisz();
  109.  
  110.  
  111.  
  112. temp2 + temp1;
  113. temp2.podajPole();
  114. temp2 - temp1;
  115. temp2.podajPole();
  116. temp2 / temp1;
  117. temp2.podajPole();
  118.  
  119. if (temp3 > temp1)
  120. {
  121. cout << "Wieksze" << endl;
  122. }
  123. else
  124. {
  125. cout << "Mniejsze" << endl;
  126. }
  127.  
  128. if (temp3 < temp1)
  129. {
  130. cout << "Wieksze" << endl;
  131. }
  132. else
  133. {
  134. cout << "Mniejsze" << endl;
  135. }
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. temp1.~Kolo();
  144. temp2.~Kolo();
  145. temp3.~Kolo();
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement