Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ShapeFactory shapeFactory = new ShapeFactory();

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

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

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

            //call draw method of Rectangle
            shape2.Draw();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //new Client().Main();
            Console.WriteLine("Выберите фигуру");
            Console.WriteLine("1. Квадрат");
            Console.WriteLine("2. Прямоугольник");
            Console.WriteLine("3. Круг");
            int    choose;
            string type;

            choose = Int32.Parse(Console.ReadLine());
            Console.Clear();
            switch (choose)
            {
            case 1:
            {
                type = "Квадрат";
                Shape shape = ShapeFactory.GetShape(type);
                Console.WriteLine(shape.Calculate());
            }
            break;

            case 2:
            {
                type = "Прямоугольник";
                Shape shape = ShapeFactory.GetShape(type);
                Console.WriteLine(shape.Calculate());
            }
            break;

            case 3:
            {
                type = "Круг";
                Shape shape = ShapeFactory.GetShape(type);
                Console.WriteLine(shape.Calculate());
            }
            break;

            default:
                break;
            }
        }