#include #include using namespace std; #include "shape.h" #include "draw_shape.h" class MyShape : public Shape { public: MyShape(Point p, RGB c, double a) : Shape(p, c, a) { } void draw() { cout << "MyShape::draw()" << endl; } }; class MyShape2 : public MyShape { public: MyShape2(Point p, RGB c, double a) : MyShape(p, c, a) { } void erase() { cout << "MyShape2::erase()" << endl; } }; int main() { Square q( Point(0.0, 0.0), RGB(255, 0, 0), 0.0, 4.5 ); Circle c( Point(10.0, -10.0), RGB(0, 255, 0), 90.0, 3.0 ); Triangle t( Point(5.0, 5.0), RGB(0, 0, 255), 180.0, 3.0, 4.0, 5.0 ); q.draw(); c.draw(); t.draw(); Point new_center(2.5, 3.5); q.erase(); q.move(new_center); q.draw(); t.erase(); t.rotate(-180.0); t.draw(); rotate_and_draw_shape(&q, 5.0); rotate_and_draw_shape(&t, 5.0); rotate_and_draw_shape(&c, 5.0); MyShape2 m(Point(1.1, 2.2), RGB(3, 4, 5), 100.0); Shape * ps; cout << endl; string s; cout << "Scegli: [s]quare, [c]ircle, [t]riangle, [m]y_shape: "; cin >> s; if(s == "s") { ps = &q; } else if(s == "c") { ps = &c; } else if(s == "t") { ps = &t; } else if(s == "m") { ps = &m; } else { cerr << "errore\n"; return 1; } rotate_and_draw_shape(ps, 10.0); MyShape2 sh(Point(0.0, 0.0), RGB(0, 0, 0), 0.0); }