コード例 #1
0
        static void Main(string[] args)
        {
            int p    = 0;
            int size = 0;

            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Выберите фигуру: " +
                              "\n1 = Треугольник,2 = Квадрат, 3 = Ромб,\n " +
                              "4 = Прямоугольник, 5 = Параллелограмм,6 = Трапеция,\n" +
                              "7 = Круг, 8 = Эллипс");
            int x = int.Parse(Console.ReadLine());

            Console.WriteLine("Выберите цвет фигуры: " +
                              "\n1 = синий,2 = красный,3 = зеленый,\n ");
            int y = int.Parse(Console.ReadLine());

            Console.WriteLine("Выберите расположение фигуры на экране: " +
                              "\n1 = слева,2 = по центру, 3 = справа,\n ");
            int z = int.Parse(Console.ReadLine());

            Console.WriteLine("Выберите размер фигуры: " +
                              "\n1 = 1, 2 = увеличить вдвое\n ");
            int r = int.Parse(Console.ReadLine());

            ColectionFigures[] colection = new ColectionFigures[size];

            switch (x)
            {
            case 1:
                size++;
                Triangle triangle = new Triangle(4, 3, 5);;
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 40;
                }
                if (z == 3)
                {
                    p = 80;
                }
                if (r == 1)
                {
                    triangle = new Triangle(4, 3, 5);
                }
                if (r == 2)
                {
                    triangle = new Triangle(8, 6, 10);
                }

                triangle.Draw(p);
                triangle.Info();
                Console.ResetColor();
                break;

            case 2:
                Square square = new Square(5);
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 40;
                }
                if (z == 3)
                {
                    p = 80;
                }
                if (r == 1)
                {
                    square = new Square(5);
                }
                if (r == 2)
                {
                    square = new Square(10);
                }
                square.Draw(p);
                square.Info();
                Console.ResetColor();
                break;

            case 3:
                Rhombus thombus = new Rhombus(10);
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 40;
                }
                if (z == 3)
                {
                    p = 90;
                }
                if (r == 1)
                {
                    thombus = new Rhombus(10);
                }
                if (r == 2)
                {
                    thombus = new Rhombus(20);
                }
                thombus.Draw(p);
                thombus.Info();
                Console.ResetColor();
                break;

            case 4:
                Rectangle rectangle = new Rectangle(4, 6);
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 40;
                }
                if (z == 3)
                {
                    p = 80;
                }
                if (r == 1)
                {
                    rectangle = new Rectangle(4, 6);
                }
                if (r == 2)
                {
                    rectangle = new Rectangle(8, 12);
                }
                rectangle.Draw(p);
                rectangle.Info();
                Console.ResetColor();
                break;

            case 5:
                Parallelogram parallelogram = new Parallelogram(4, 6);
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 40;
                }
                if (z == 3)
                {
                    p = 80;
                }
                if (r == 1)
                {
                    parallelogram = new Parallelogram(4, 6);
                }
                if (r == 2)
                {
                    parallelogram = new Parallelogram(8, 12);
                }
                parallelogram.Draw(p);
                parallelogram.Info();
                Console.ResetColor();
                break;

            case 6:
                Trapezoid trapezoid = new Trapezoid(6, 14, 6, 8, 4);
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 20;
                }
                if (z == 3)
                {
                    p = 60;
                }
                if (r == 1)
                {
                    trapezoid = new Trapezoid(6, 14, 6, 8, 4);
                }
                if (r == 2)
                {
                    trapezoid = new Trapezoid(12, 28, 12, 16, 8);
                }
                trapezoid.Draw(p);
                trapezoid.Info();
                Console.ResetColor();
                break;

            case 7:
                Circle circle = new Circle(4);
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 40;
                }
                if (z == 3)
                {
                    p = 80;
                }
                if (r == 1)
                {
                    circle = new Circle(4);
                }
                if (r == 2)
                {
                    circle = new Circle(8);
                }
                circle.Draw(p);
                circle.Info();
                Console.ResetColor();
                break;

            case 8:
                Ellipse ellipse = new Ellipse(8, 6);
                if (y == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (y == 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (y == 3)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (z == 1)
                {
                    p = 0;
                }
                if (z == 2)
                {
                    p = 40;
                }
                if (z == 3)
                {
                    p = 80;
                }
                ellipse.Draw(p);
                ellipse.Info();
                Console.ResetColor();
                break;
            }


            Console.WriteLine("Вывести все фигуры на экран? 1 - да, 2 - нет");

            try
            {
                int q = int.Parse(Console.ReadLine());
                switch (q)
                {
                case 1:
                    Console.Clear();

                    Circle circle = new Circle(4);
                    circle.Draw(0);
                    circle.Info();

                    Ellipse ellipse = new Ellipse(8, 6);
                    ellipse.Draw(0);
                    ellipse.Info();

                    Square square = new Square(4);
                    square.Draw(0);
                    square.Info();

                    Rectangle rectangle = new Rectangle(4, 6);
                    rectangle.Draw(0);
                    rectangle.Info();

                    Trapezoid trapezoid = new Trapezoid(2, 4, 6, 8, 4);
                    trapezoid.Draw(0);
                    trapezoid.Info();

                    Parallelogram parallelogram = new Parallelogram(4, 6);
                    parallelogram.Draw(0);
                    parallelogram.Info();

                    Rhombus thombus = new Rhombus(10);
                    thombus.Draw(0);
                    thombus.Info();

                    Rhombus rhombus = new Rhombus(6);
                    rhombus.Draw(0);
                    rhombus.Info();

                    break;

                case 2:
                    break;
                }
            }
            catch
            {
                Console.WriteLine("Not right simbol");
            }



            //Console.CursorSize = 26;
            //Console.CursorLeft = 25;

            //Console.SetCursorPosition(50, 25);
            //Console.Beep();

            //Console.Beep();
            //

            //var x = Console.CursorLeft;
            //var y = Console.CursorTop;
            //Console.WriteLine($"x = {x}, y = {y}");

            //x = Console.CursorLeft+25;
            //y = Console.CursorTop;
            //Console.WriteLine($"x = {x}, y = {y}");

            //Console.SetCursorPosition(x, y);
            //Console.WriteLine("@");

            //ColectionFigures[] figures = new ColectionFigures[2];
            //figures[0] = new Square(5);
            //figures[1] = new Rectangle(4, 6);


            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            void Color_Set()
            {
                int sch;

                Console.WriteLine("Выбор цвета");
                Console.WriteLine("Blue    - 1");
                Console.WriteLine("Gray    - 2");
                Console.WriteLine("Green   - 3");
                Console.WriteLine("Cyan    - 4");
                Console.WriteLine("Red     - 5");
                Console.WriteLine("Magenta - 6");
                Console.WriteLine("Yellow  - 7");
                Console.WriteLine("White   - 8");
                Console.Write("  Ваш выбор - ");
                sch = int.Parse(Console.ReadLine());
                switch (sch)
                {
                case 1:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Blue;
                    break;
                }

                case 2:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Gray;
                    break;
                }

                case 3:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Green;
                    break;
                }

                case 4:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Cyan;
                    break;
                }

                case 5:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Red;
                    break;
                }

                case 6:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Magenta;
                    break;
                }

                case 7:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Yellow;
                    break;
                }

                case 8:
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.White;
                    break;
                }

                default: { break; }
                }
            }

            //-------------------------------------------------------
            Rectangle f  = new Rectangle(4, 8);
            Rhombus   f1 = new Rhombus(9);
            Triangle  f3 = new Triangle(15);
            Trapezoid f4 = new Trapezoid(9, 18);

            string[] df = new string[4];
            int      z1, z2 = 0;
            int      i = 0;

            do
            {
                Console.ResetColor();
                Console.Clear();
                Console.WriteLine("     M Е Н Ю ");
                Console.WriteLine("   ПРЯМОУГОЛЬНИК          - 1");
                Console.WriteLine("       РОМБ               - 2");
                Console.WriteLine("    ТРЕУГОЛЬНИК           - 3");
                Console.WriteLine("      ТРАПЕЦИЯ            - 4");
                Console.WriteLine("ПОКАЗАТЬ ВЫБРАННЫЕ ФИГУРЫ - 5");
                Console.WriteLine("             В Ы Х О Д    - 6");
                Console.Write("             Ваш выбор - ");
                z1 = int.Parse(Console.ReadLine());

                switch (z1)
                {
                case 1:
                {
                    Color_Set();
                    f.ShowName();
                    f.Draw();
                    df[i] = f.name;
                    i++;
                    break;
                }

                case 2:
                {
                    Color_Set();
                    f1.ShowName();
                    f1.Draw();
                    df[i] = f1.name;
                    i++;
                    break;
                }

                case 3:
                {
                    Color_Set();
                    f3.ShowName();
                    f3.Draw();
                    df[i] = f3.name;
                    i++;
                    break;
                }

                case 4:
                {
                    Color_Set();
                    f4.ShowName();
                    f4.Draw();
                    df[i] = f4.name;
                    i++;
                    break;
                }

                case 5:
                {
                    while (i < 4)
                    {
                        Console.WriteLine(df[i]);
                        i++;
                    }
                    break;
                }
                }
                Console.WriteLine("Для продолжения нажмите 1, для выхода 0");
                z2 = int.Parse(Console.ReadLine());
            } while (z2 == 1);
        }