34 lines
538 B
C
34 lines
538 B
C
|
#include "first_interface.h"
|
||
|
|
||
|
class ShapeDecorator
|
||
|
{
|
||
|
public:
|
||
|
ShapeDecorator(Shape *shape)
|
||
|
{
|
||
|
this->shape = shape;
|
||
|
}
|
||
|
virtual ~ShapeDecorator(){}
|
||
|
virtual void draw()
|
||
|
{
|
||
|
shape->draw();
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
Shape *shape;
|
||
|
};
|
||
|
|
||
|
class RedShapeDecorator: public ShapeDecorator
|
||
|
{
|
||
|
public:
|
||
|
RedShapeDecorator(Shape *shape) : ShapeDecorator(shape){}
|
||
|
void setRedBorder()
|
||
|
{
|
||
|
cout << "Border color: Red" << endl;
|
||
|
}
|
||
|
void draw()
|
||
|
{
|
||
|
shape->draw();
|
||
|
setRedBorder();
|
||
|
}
|
||
|
};
|