Guest User

Untitled

a guest
Dec 11th, 2019
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. const double boxDefaultSize = 1;
  4.  
  5. class Box
  6. {
  7. public:
  8. Box()
  9. {
  10. this->m_x = new double;
  11. this->m_y = new double;
  12. this->m_z = new double;
  13. *m_x = boxDefaultSize;
  14. *m_y = boxDefaultSize;
  15. *m_z = boxDefaultSize;
  16. }
  17.  
  18. Box(Box &temp)
  19. {
  20. this->m_x = new double;
  21. this->m_y = new double;
  22. this->m_z = new double;
  23. *m_x = temp.GetX();
  24. *m_y = temp.GetY();
  25. *m_z = temp.GetZ();
  26. }
  27.  
  28. Box(double x, double y, double z)
  29. {
  30. this->m_x = new double;
  31. this->m_y = new double;
  32. this->m_z = new double;
  33. *m_x = x;
  34. *m_y = y;
  35. *m_z = z;
  36. }
  37.  
  38. ~Box()
  39. {
  40. m_x = NULL;
  41. m_y = NULL;
  42. m_z = NULL;
  43. delete m_x;
  44. delete m_y;
  45. delete m_z;
  46. }
  47.  
  48. double GetX () { return *m_x;}
  49.  
  50. double GetY () { return *m_y;}
  51.  
  52. double GetZ () { return *m_z;}
  53.  
  54. double GetV () { return *m_z**m_y**m_x; }
  55.  
  56. bool IsEqual(Box &temp)
  57. {
  58. if(*m_x == temp.GetX()
  59. && *m_y == temp.GetY()
  60. && *m_z == temp.GetZ())
  61. return true;
  62. return false;
  63. }
  64.  
  65. private:
  66. double *m_x;
  67. double *m_y;
  68. double *m_z;
  69. };
  70.  
  71. int main()
  72. {
  73. Box defaultBox;
  74.  
  75. double x,y,z;
  76.  
  77. Box currentBox(-1,-1,-1);
  78.  
  79. while(!defaultBox.IsEqual(currentBox))
  80. {
  81. std::cout << "vavedi xyz:" << std::endl;
  82. std::cin >> x >> y >> z;
  83. currentBox = Box(x,y,z);
  84.  
  85. double currentV = currentBox.GetV();
  86.  
  87. std::cout << "v = " << currentV << std::endl;
  88.  
  89. if(currentV < 1)
  90. std::cout << "malka kutiq" << std::endl;
  91. else if (currentV > 1 && currentV < 5)
  92. std::cout << "sredna kutiq" << std::endl;
  93. else
  94. std::cout << "golqma kutiq" << std::endl;
  95.  
  96. std::cout << currentBox.GetX() << " " << currentBox.GetY() << " " << currentBox.GetZ() << std::endl;
  97. }
  98. }
RAW Paste Data