Advertisement
tei123

programowanie lab 8 zrobione pole class zle

May 8th, 2018
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. class Trojkat
  7. {
  8. private:
  9. float x, y, z, obw2, pole;
  10.  
  11. public:
  12. void newTrojkat()
  13. {
  14. x=0;
  15. y=0;
  16. z=0;
  17. }
  18.  
  19. void newTrojkat(Trojkat &a)
  20. {
  21. x=a.x;
  22. y=a.y;
  23. z=a.z;
  24. static bool SprawdzXYZ(float x, float y, float z)
  25. {
  26. if(x>0 && y>0 && z>0)
  27. return true;
  28. else return false;
  29. if(x<y+z || y<x+z || z<x+y)
  30. return true;
  31. else return false;
  32. }
  33.  
  34. void UstawXYZ(float newx, float newy, float newz)
  35. {
  36. Trojkat a;
  37. a.x=newx;
  38. a.y=newy;
  39. a.z=newz;
  40.  
  41. if(a.SprawdzXYZ())
  42. {
  43. newTrojkat(a);
  44. }
  45. }
  46.  
  47.  
  48. private:
  49. void ObliczObw2()
  50. {
  51. obw2=(x+y+z)/2;
  52. }
  53.  
  54. void ObliczPole()
  55. {
  56. pole=2*sqrt((obw2-x)*(obw2-y)*(obw2-z));
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement