Beispiel #1
0
        static void Main(string[] args)
        {
            var figure = Console.ReadLine();
            CorDraw corDraw;

            switch (figure)
            {
                case "Square":
                    var size = int.Parse(Console.ReadLine());
                    var square = new Square(size);
                    corDraw = new CorDraw(square);
                    break;
                case "Rectangle":
                    var width = int.Parse(Console.ReadLine());
                    var height = int.Parse(Console.ReadLine());
                    var rectangle = new Rectangle(width, height);
                    corDraw = new CorDraw(rectangle);
                    break;
                default:
                    throw new ArgumentException();
            }

            corDraw.DrawFigure();
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     string input = Console.ReadLine();
     Figure figure;
     switch(input)
     {
         case "Square":
             int size = int.Parse(Console.ReadLine());
              figure = new Square(size, size);
             CorDraw drawFig = new CorDraw(figure);
             drawFig.drawFigure();
             break;
         case "Rectangle":
             int sizeA = int.Parse(Console.ReadLine());
             int sizeB = int.Parse(Console.ReadLine());
              figure = new Rectangle(sizeA, sizeB);
             CorDraw drawFg = new CorDraw(figure);
             drawFg.drawFigure();
             break;
     }
 }