fork download
  1. #include<iostream>
  2. #include<fstream>
  3. #include<cmath>
  4. #include "quadrilateral.h"
  5. using namespace std;
  6.  
  7. void Quadrilateral::validate()
  8. {
  9. Quadrilateral p1, p2, p3, p4;
  10. if(p1.x < p2.x && p1.y == p2.y && p4.x < p3.x && p4.y == p3.y)
  11. {
  12. a = p1;
  13. b = p2;
  14. c = p3;
  15. d = p4;
  16. }
  17. else
  18. {
  19. cout << "Incorrect order. Here are the coordinates";
  20. cout << " in the correct order:" << endl;
  21. Quadrilateral();
  22. }
  23. }
  24.  
  25. Quadrilateral::Quadrilateral()
  26. {
  27. a = Point(-1,-1);
  28. b = Point(3,0);
  29. c = Point(2,2);
  30. d = Point(1,1);
  31. }
  32.  
  33. Quadrilateral::Quadrilateral(Point &p1, Point &p2, Point &p3, Point &p4)
  34. {
  35. SetAll(p1,p2,p3,p4);
  36. validate();
  37. }
  38.  
  39. void Quadrilateral::SetA(Point &p1)
  40. {
  41. a = p1;
  42. return;
  43. }
  44.  
  45. void Quadrilateral::SetB(Point &p2)
  46. {
  47. b = p2;
  48. return;
  49. }
  50.  
  51. void Quadrilateral::SetC(Point &p3)
  52. {
  53. c = p3;
  54. return;
  55. }
  56.  
  57. void Quadrilateral::SetD(Point &p4)
  58. {
  59. d = p4;
  60. return;
  61. }
  62.  
  63. void Quadrilateral::SetAll(Point &p1, Point &p2, Point &p3, Point &p4)
  64. {
  65. a = p1;
  66. b = p2;
  67. c = p3;
  68. d = p4;
  69. validate();
  70. return;
  71. }
  72.  
  73. Point Quadrilateral::GetA(void) const
  74. {
  75. return a;
  76. }
  77.  
  78. Point Quadrilateral::GetB(void) const
  79. {
  80. return b;
  81. }
  82.  
  83. Point Quadrilateral::GetC(void) const
  84. {
  85. return c;
  86. }
  87.  
  88. Point Quadrilateral::GetD(void) const
  89. {
  90. return d;
  91. }
  92.  
  93. double Quadrilateral::Perimeter()
  94. {
  95. double side1 = a.Distance(b);
  96. double side2 = b.Distance(c);
  97. double side3 = c.Distance(d);
  98. double side4 = d.Distance(a);
  99. return(side1 + side2 + side3 + side4);
  100. }
  101.  
  102. double Quadrilateral::Area()
  103. {
  104. double side1 = a.Distance(b);
  105. double side2 = b.Distance(c);
  106. double side3 = c.Distance(a);
  107. double side4 = c.Distance(d);
  108. double side5 = d.Distance(a);
  109. double semi1 = (side1 + side2 + side3)/2;
  110. double semi2 = (side3 + side4 + side5)/2;
  111. double area1 = sqrt(semi1 * (semi1 - side1) *
  112. (semi1 - side2) * (semi1 - side3));
  113. double area2 = sqrt(semi2 * (semi2 - side3) * (semi2 - side4)
  114. * (semi2 - side5));
  115. return(area1 + area2);
  116. }
  117.  
  118. void Quadrilateral::Print()
  119. {
  120. Quadrilateral p1, p2, p3, p4;
  121. cout << "I'm a Quadrilateral" << endl;
  122. cout << "(" << p1.x << "," << p1.y << "), (" << p2.x << ","
  123. << p2.y << "), (" << p3.x << "," << p3.y << "), (" << p4.x
  124. << "," << p4.y << ")" << endl;
  125. }
  126.  
  127.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:27: fatal error: quadrilateral.h: No such file or directory
 #include "quadrilateral.h"
                           ^
compilation terminated.
stdout
Standard output is empty