#include #include #include #include #include "polygon.h" Polygon::Polygon(int n): num_vertices(n) { int i; vertices = new point[num_vertices]; centre.x = centre.y = 0.0; for (i=0;i> vertices[i].x >> vertices[i].y; centre.x += vertices[i].x; centre.y += vertices[i].y; } centre.x /= num_vertices; centre.y /= num_vertices; } Polygon::Polygon(char *name) { int i; ifstream ins(name); if (ins.fail()) { cerr << "Error opening " << name << endl; num_vertices = 0; } else { ins >> num_vertices; vertices = new point[num_vertices]; for (i=0;i> vertices[i].x >> vertices[i].y; } ins >> centre.x >> centre.y; ins.close(); } } Polygon::Polygon(const Polygon& p): num_vertices(p.num_vertices) { int i; vertices = new point[num_vertices]; for (i=0;i