#ifndef _POLY_H_ #define _POLY_H_ #include #include "canvas.h" #include "shape.h" /* Points for the polygon. */ class Point { private: int _x, _y; public: Point(int x, int y) { _x = x; _y = y; } int x() { return _x; } int y() { return _y; } void move(int dx, int dy) { _x += dx; _y += dy; } }; /* A polygon to which you can add points. */ /* Relation to origen: The first point added is the origen. All additional points added are stored relative to the current origen. */ class Polygon: public Shape { private: Point *pts; // Array of points. int ptsize; // Size of the array. int npts; // Number therein. public: Polygon(): Shape(0,0) { pts = new Point[ptsize = 10]; npts = 0; } Polygon(int npts, Point *pts): Shape(0, 0); ~Polygon() { delete pts; } virtual void draw(Drawable &d); void add(int x, int y) { add(Point(x,y); } void add(Point p); void add(int npts, Point *pts); }; #endif