Пример #1
0
        static void Main(string[] args)
        {
            string[,] canvas = new string [0,0];
            bool quit = false;
            ITool tool = null;

            while (!quit)
            {
                Console.Write("enter command: ");
                string line;
                while ((line = Console.ReadLine().Trim()) == "") ;
                args = line.Split(' ');
                switch (args[0].ToUpper())
                {
                    case "C":
                        tool = new CanvasArea(canvas, args);
                        break;
                    case "L":
                        tool = new Line(canvas, args);
                        break;
                    case "R":
                        tool = new Rectangle(canvas, args);
                        break;
                    case "B":
                        tool = new BucketFill(canvas, args);
                        break;
                    case "Q":
                        quit = true;
                        break;
                    default:
                        Console.WriteLine("you entered unrecognized command");
                        tool = null;
                        break;
                }

                if (tool != null)
                {
                    if (tool.Validate())
                    {
                        canvas = tool.Create();
                        DrawHelper.DisplayDrawing(canvas);
                    }
                    else
                    {
                        Console.WriteLine("you entered invalid command");
                    }
                }
            }
        }
Пример #2
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();
        }
Пример #3
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;
     }
 }