public IHaveArea ReceiveFigure(IHaveArea figure)
        {
            var decoratedFigure = new ZoomDecorator(figure);

            decoratedFigure.Zoom = this.currentZoom;
            this.figures.Add(decoratedFigure);
            return(decoratedFigure);
        }
예제 #2
0
        public static void withNaiveZoom()
        {
            var figures = new List <IHaveArea>();

            figures.Add(new Square(new RectangleAreaEquation()));
            figures.Add(new Rectangle(new RectangleAreaEquation()));
            figures.Add(new Parralelogram(new ParralelogramAreaEquation()));

            var squareCanBeZoomed = new ZoomDecorator(new Square(new RectangleAreaEquation()));

            figures.Add(squareCanBeZoomed);

            // использование декоратора (наивный пример)
            squareCanBeZoomed.Zoom = 5;
        }