public static void Main()
        {
            ShapeFactory factory = new ShapeFactory();

            IShape rectangle = factory.GetShape(Shape.Rectangle);

            Console.WriteLine(rectangle.GetDescription());

            IShape circle = factory.GetShape(Shape.Circle);

            Console.WriteLine(circle.GetDescription());

            IShape square = factory.GetShape(Shape.Square);

            Console.WriteLine(square.GetDescription());
        }
Exemple #2
0
        public static void Main(String[] args)
        {
            ShapeFactory shapeFactory = new ShapeFactory();

            //get an object of Circle and call its draw method.
            IShape shape1 = shapeFactory.getShape("CIRCLE");

            //call draw method of Circle
            shape1.draw();

            //get an object of Rectangle and call its draw method.
            IShape shape2 = shapeFactory.getShape("RECTANGLE");

            //call draw method of Rectangle
            shape2.draw();

            //get an object of Square and call its draw method.
            IShape shape3 = shapeFactory.getShape("SQUARE");

            //call draw method of circle
            shape3.draw();

            Console.ReadKey();
        }