fork download
  1. #include<iostream>
  2. #include<cmath>
  3. #include "trapezoid.h"
  4. using namespace std;
  5.  
  6. Trapezoid::Trapezoid():Quadrilateral()
  7. {
  8. a = Point(1,1);
  9. b = Point(6,1);
  10. c = Point(5,4);
  11. d = Point(2,4);
  12. }
  13.  
  14. Trapezoid::Trapezoid(Point &p1, Point &p2, Point &p3, Point &p4):
  15. Quadrilateral(p1,p2,p3,p4)
  16. {
  17. validate();
  18. }
  19.  
  20. void Trapezoid::SetAll(Point &p1, Point &p2, Point &p3, Point &p4)
  21. {
  22. Quadrilateral::SetAll(p1,p2,p3,p4);
  23. validate();
  24. }
  25.  
  26. double Trapezoid::Perimeter()
  27. {
  28. double side1 = a.Distance(b);
  29. double side2 = b.Distance(c);
  30. double side3 = c.Distance(d);
  31. double side4 = d.Distance(a);
  32. return(side1 + side2 + side3 + side4);
  33. }
  34.  
  35. double Trapezoid::Area()
  36. {
  37. double side1 = a.Distance(b);
  38. double side2 = b.Distance(c);
  39. double side3 = c.Distance(d);
  40. double side4 = d.Distance(a);
  41. double shortLeg = (side1 - side3)/2;
  42. double height = sqrt((side2 * side2) - (shortLeg * shortLeg));
  43. return((height * (side1 + side3))/2);
  44. }
  45.  
  46. void Trapezoid::Print()
  47. {
  48. cout << "I'm a Trapezoid" << endl;
  49. Quadrilateral::Print();
  50. }
  51.  
  52.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:23: fatal error: trapezoid.h: No such file or directory
 #include "trapezoid.h"
                       ^
compilation terminated.
stdout
Standard output is empty