예제 #1
0
        /// <summary>
        /// Reading from console for TASK2.
        /// </summary>
        public static void ConsoleTASK2()
        {
            Console.WriteLine("------TASK1------");
            P2.Square    square    = new P2.Square();
            P2.Rectangle rectangle = new P2.Rectangle();

            Console.Write("class Square : ");
            square.Draw();
            Console.WriteLine();
            Console.Write("class Rectangle : ");
            rectangle.Draw();
            Console.WriteLine();

            Console.WriteLine("------TASK2------");
            Console.WriteLine("Square");
            Console.Write("Enter x: ");
            int x1 = int.Parse(Console.ReadLine());

            Console.Write("Enter y: ");
            int y1 = int.Parse(Console.ReadLine());

            P2.Abstract.Square square1 = new P2.Abstract.Square(x1, y1);
            square1.Draw();
            Console.WriteLine();

            Console.WriteLine("Rectangle");
            Console.Write("Enter x: ");
            int x2 = int.Parse(Console.ReadLine());

            Console.Write("Enter y: ");
            int y2 = int.Parse(Console.ReadLine());

            P2.Abstract.Rectangle rectangle1 = new P2.Abstract.Rectangle(x2, y2);
            rectangle1.Draw();
            Console.WriteLine();

            Console.WriteLine("------TASK3------");

            Console.WriteLine("Figure");
            Console.Write("Enter x: ");
            int x3 = int.Parse(Console.ReadLine());

            Console.Write("Enter y: ");
            int y3 = int.Parse(Console.ReadLine());

            P2.Virtual.Figure figure2 = new P2.Virtual.Figure(x3, y3);
            figure2.Draw();
            Console.WriteLine();

            Console.WriteLine("Square");
            Console.Write("Enter x: ");
            int x4 = int.Parse(Console.ReadLine());

            Console.Write("Enter y: ");
            int y4 = int.Parse(Console.ReadLine());

            P2.Virtual.Square square2 = new P2.Virtual.Square(x4, y4);
            square2.Draw();
            Console.WriteLine();

            Console.WriteLine("Rectangle");
            Console.Write("Enter x: ");
            int x5 = int.Parse(Console.ReadLine());

            Console.Write("Enter y: ");
            int y5 = int.Parse(Console.ReadLine());

            P2.Virtual.Rectangle rectangle2 = new P2.Virtual.Rectangle(x5, y5);
            rectangle2.Draw();
            Console.WriteLine();

            Console.WriteLine("------TASK4------");
            Interface.IDrawable[] drawables = new Interface.IDrawable[]
            {
                new Interface.Figure(2, 6),
                new Interface.Square(7, -2),
                new Interface.Square(-2, 5),
                new Interface.Figure(5, 2),
                new Interface.Square(0, 0),
                new Interface.Rectangle(1, 2)
            };
            P2.Interface.Addition.DrawAll(drawables);
            Console.WriteLine();
            Console.ReadKey();
        }
예제 #2
0
        /// <summary>
        /// Reading from file for TASK2.
        /// </summary>
        public static void ReadFileTASK2()
        {
            string[] lines = File.ReadAllLines(@"fileTASK2.txt");

            Console.WriteLine("------TASK1------");
            P2.Square    square    = new P2.Square();
            P2.Rectangle rectangle = new P2.Rectangle();

            Console.Write("class Square : ");
            square.Draw();
            Console.WriteLine();
            Console.Write("class Rectangle : ");
            rectangle.Draw();
            Console.WriteLine();

            Console.WriteLine("------TASK2------");
            var line1 = lines[0].Split(',');

            Console.WriteLine("Square");
            P2.Abstract.Square square1 = new P2.Abstract.Square(int.Parse(line1[0]), int.Parse(line1[1]));
            square1.Draw();
            Console.WriteLine();

            Console.WriteLine("Rectangle");
            var line2 = lines[1].Split(',');

            P2.Abstract.Rectangle rectangle1 = new P2.Abstract.Rectangle(int.Parse(line2[0]), int.Parse(line2[1]));
            rectangle1.Draw();
            Console.WriteLine();

            Console.WriteLine("------TASK3------");

            Console.WriteLine("Figure");
            var line3 = lines[2].Split(',');

            P2.Virtual.Figure figure2 = new P2.Virtual.Figure(int.Parse(line3[0]), int.Parse(line3[1]));
            figure2.Draw();
            Console.WriteLine();

            Console.WriteLine("Square");
            var line4 = lines[3].Split(',');

            P2.Virtual.Square square2 = new P2.Virtual.Square(int.Parse(line4[0]), int.Parse(line4[1]));
            square2.Draw();
            Console.WriteLine();

            Console.WriteLine("Rectangle");
            var line5 = lines[4].Split(',');

            P2.Virtual.Rectangle rectangle2 = new P2.Virtual.Rectangle(int.Parse(line5[0]), int.Parse(line5[1]));
            rectangle2.Draw();
            Console.WriteLine();

            Console.WriteLine("------TASK4------");
            Interface.IDrawable[] drawables = new Interface.IDrawable[]
            {
                new Interface.Figure(int.Parse(lines[5].Split(',')[0]), int.Parse(lines[5].Split(',')[1])),
                new Interface.Square(int.Parse(lines[6].Split(',')[0]), int.Parse(lines[6].Split(',')[1])),
                new Interface.Square(int.Parse(lines[7].Split(',')[0]), int.Parse(lines[7].Split(',')[1])),
                new Interface.Figure(int.Parse(lines[8].Split(',')[0]), int.Parse(lines[8].Split(',')[1])),
                new Interface.Square(int.Parse(lines[9].Split(',')[0]), int.Parse(lines[9].Split(',')[1]))
            };
            P2.Interface.Addition.DrawAll(drawables);
            Console.WriteLine();
            Console.ReadKey();
        }