Polygon.h 648 B

1234567891011121314151617181920212223242526272829303132
  1. #include "Figure.h"
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5. class Polygon: public Figure
  6. {
  7. private:
  8. vector<Point> points;
  9. void init(vector<struct Point> init_points);
  10. void sort_points();
  11. public:
  12. template <typename T>
  13. Polygon(vector<T> init_points)
  14. {
  15. for(int i = 0; i < init_points.lenght; i+=2)
  16. struct Point p;
  17. p.x = init_points[i];
  18. p.y = init_points[i+1];
  19. points.push_back(p);
  20. }
  21. Polygon(vector<struct Point> init_points);
  22. Polygon(string file_path);
  23. double calc_area();
  24. double calc_perimiter();
  25. void name();
  26. };