Advertisement
SIKER_98

test

Jan 28th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. int main() {
  2. Point *p1 = new Point(0, 0);
  3. Point *p2 = new Point(0, 4);
  4. Point *p3 = new Point(4, 4);
  5. Point *p4 = new Point(4, 0);
  6. Point *p5 = new Point(4, -4);
  7. Point *p6 = new Point(0, -4);
  8.  
  9. cout << "---POINT---" << endl;
  10.  
  11. cout << p1->getDistance(p2) << endl; // 4
  12. cout << p1->getDistance(p6) << endl; // 4
  13. cout << p1->getDistance(p3) << endl; // 5.65685
  14.  
  15. /*
  16. cout << "---LINE---" << endl;
  17. Line *l1 = new Line(p1, p2);
  18. Line *l2 = new Line(p1, p3);
  19. Line *l3 = new Line(p3, p1);
  20. Line *l4 = new Line(p3, p6);
  21.  
  22. cout << l1->getLength() << endl; // 4
  23. cout << l2->getLength() << endl; // 5.65685
  24. cout << l3->getLength() << endl; // 5.65685
  25. cout << l4->getLength() << endl; // 8.94427
  26.  
  27. cout <<"a1 " << l1->getA() << " | b1 " << l1->getB() << endl;
  28. cout <<"a2 " << l2->getA() << " | b2 " << l2->getB() << endl;
  29. cout <<"a3 " << l3->getA() << " | b3 " << l3->getB() << endl;
  30. cout <<"a4 " << l4->getA() << " | b4 " << l4->getB() << endl;
  31. */
  32.  
  33.  
  34. cout << "---SHAPE---" << endl;
  35. Shape *s1 = new Shape();
  36. s1->addPoint(p1);
  37. s1->addPoint(p2);
  38. s1->addPoint(p3);
  39. s1->addPoint(p4);
  40. cout << s1->getCircumference() << endl; // 16
  41. cout << s1->getArea() << endl; // 16
  42.  
  43. Shape *s2 = new Shape();
  44. s2->addPoint(p1);
  45. s2->addPoint(p2);
  46. s2->addPoint(p3);
  47. s2->addPoint(p4);
  48. s2->addPoint(p5);
  49. s2->addPoint(p6);
  50. cout << s2->getCircumference() << endl; // 24
  51. cout << s2->getArea() << endl; // 32
  52. cout << s2->getPoint(3)->getDistance(s2->getPoint(2)) << endl; //4
  53.  
  54.  
  55. cout << "---TRIANGLE---" << endl;
  56. Triangle *t1 = new Triangle(p1, p2, p3);
  57. cout << t1->getCircumference() << endl; // 13.6569
  58. cout << t1->getArea() << endl; // 8
  59. Triangle *t2 = new Triangle(p1, p3, p5);
  60. cout << t2->getCircumference() << endl; // 19.3137
  61. cout << t2->getArea() << endl; // 16
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement