Esempio n. 1
0
        static void Main(string[] args)
        {
            var circle = new Circle(2);

            WriteLine(circle.AsString());

            var redSquare = new ColoredShape(circle, "red");

            WriteLine(redSquare.AsString());

            var redHalfTransparentSquare = new TransparentShape(redSquare, 0.5f);

            WriteLine(redHalfTransparentSquare.AsString());

            // static
            ColoredShape <Circle> blueCircle = new ColoredShape <Circle>("blue");

            WriteLine(blueCircle.AsString());
            // A circle of radius 0 has the color blue

            TransparentShape <ColoredShape <Square> > blackHalfSquare = new TransparentShape <ColoredShape <Square> >(0.4f);

            WriteLine(blackHalfSquare.AsString());
            // A square with side 0 has the color black has transparency 40
        }
Esempio n. 2
0
        public static void Start()
        {
            var square = new Square(1.23f);

            WriteLine(square.AsString());

            var redSquare = new ColoredShape(square, "red");

            WriteLine(redSquare.AsString());

            var redHalfTransparentSquare = new TransparentShape(redSquare, 0.5f);

            WriteLine(redHalfTransparentSquare.AsString());

            // static
            ColoredShape <Circle> blueCircle = new ColoredShape <Circle>("blue");

            WriteLine(blueCircle.AsString());

            TransparentShape <ColoredShape <Square> > blackHalfSquare = new TransparentShape <ColoredShape <Square> >(0.4f);

            WriteLine(blackHalfSquare.AsString());
        }
        static void Main(string[] args)
        {
            var square = new Square(1.23f);

            WriteLine(square.AsString());

            var redSquare = new ColoredShape(square, "red");

            WriteLine(redSquare.AsString());

            var redHalfTransparentSquare = new TransparentShape(redSquare, 0.5f);

            WriteLine(redHalfTransparentSquare.AsString());

            // static
            ColoredShape <Circle> blueCircle = new ColoredShape <Circle>("blue");

            WriteLine(blueCircle.AsString());

            // limitation: cannot change color or side
            TransparentShape <ColoredShape <Square> > blackHalfSquare = new TransparentShape <ColoredShape <Square> >(0.4f);

            WriteLine(blackHalfSquare.AsString());
        }