public static void Run() { IDrawable redCircle = new RedShapeDecorator(new Circle()); IDrawable blueRectangle = new BlueShapeDecorator(new Rectangle()); Console.WriteLine("<Decorator Pattern Example>"); Console.WriteLine(); Console.Write("\t"); redCircle.Draw(); Console.Write("\t"); blueRectangle.Draw(); Console.WriteLine(); Console.WriteLine("</Decorator Pattern Example>"); Console.WriteLine(); }
static void DecoratorTest() { Decorator.IShape circle = new Decorator.Circle(); Decorator.IShape redCircle = new RedShapeDecorator(new Decorator.Circle()); Decorator.IShape blueCircle = new BlueShapeDecorator(new Decorator.Circle()); Decorator.IShape redRectangle = new RedShapeDecorator(new Decorator.Rectangle()); Decorator.IShape redBlueCircle = new RedShapeDecorator(new BlueShapeDecorator(new Decorator.Circle())); Console.WriteLine("Circle with normal border"); circle.draw(); Console.WriteLine("\nCircle of red border"); redCircle.draw(); Console.WriteLine("\nRectangle of red border"); redRectangle.draw(); Console.WriteLine("\nCircle of red and blue border "); redBlueCircle.draw(); }