fork download
  1. #include<iostream>
  2. #include<cmath>
  3. #include "parallelogram.h"
  4. using namespace std;
  5.  
  6. Parallelogram::Parallelogram():Quadrilateral()
  7. {
  8. a = Point(-5,-1);
  9. b = Point(4,-1);
  10. c = Point(6,4);
  11. d = Point(-3,4);
  12. }
  13.  
  14. Parallelogram::Parallelogram(Point &p1, Point &p2, Point &p3, Point &p4):
  15. Quadrilateral(p1,p2,p3,p4)
  16. {
  17. validate();
  18. }
  19.  
  20. void Parallelogram::SetAll(Point &p1, Point &p2, Point &p3, Point &p4)
  21. {
  22. Quadrilateral::SetAll(p1,p2,p3,p4);
  23. validate();
  24. }
  25.  
  26. double Parallelogram::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 Parallelogram::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((side4 * side4) - (shortLeg * shortLeg));
  43. return(height * side1);
  44. }
  45.  
  46. void Parallelogram::Print()
  47. {
  48. cout << "I'm a Parallelogram" << 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:27: fatal error: parallelogram.h: No such file or directory
 #include "parallelogram.h"
                           ^
compilation terminated.
stdout
Standard output is empty