Пример #1
0
 public override void printAll(colorDelegate color)
 {
     Console.Clear();
     if (list.Count == 0)
     {
         Console.WriteLine("Вы не добавили фигуры для отображения. Нажмите любую клавишу");
         Thread.Sleep(2000);
     }
     for (int i = 0; i < list.Count; i++)
     {
         Console.WriteLine($"Выберите цвет для {list[i].name}");
         color();
         //ConsoleColor color = ConsoleColor.Green;
         //Console.ForegroundColor = color;
         Console.WriteLine();
         list[i].print();
         Console.WriteLine();
         Console.ResetColor();
         if (i == list.Count - 1)
         {
             Console.WriteLine("Фигуры отображены. Нажмите любую клавишу");
         }
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            Figure        figure = new Figure();
            bool          go_on  = true;
            colorDelegate color  = setColor;

            try
            {
                while (go_on)
                {
                    Console.Clear();
                    Console.WriteLine("Выберите фигуры для отображения в консоли");
                    Console.WriteLine("*******************************");
                    Console.WriteLine("1 - прямоугольник");
                    Console.WriteLine("2 - ромб");
                    Console.WriteLine("3 - треугольник");
                    Console.WriteLine("4 - трапеция");
                    Console.WriteLine("5 - многоугольник");
                    Console.WriteLine("6 - отобразить выбранные фигуры");
                    Console.WriteLine("0 - Выход из программы");
                    Console.WriteLine("*******************************");

                    switch (_getch())
                    {
                    case '1':
                        figure.list.Add(new rectangle());
                        Console.WriteLine("Прямоугольник добавлен");
                        Thread.Sleep(1000);
                        break;

                    case '2':
                        figure.list.Add(new diamond());
                        Console.WriteLine("ромб добавлен");
                        Thread.Sleep(1000);
                        break;

                    case '3':
                        figure.list.Add(new triangle());
                        Console.WriteLine("треугольник добавлен");
                        Thread.Sleep(1000);
                        break;

                    case '4':
                        figure.list.Add(new trapezoid());
                        Console.WriteLine("трапеция добавлена");
                        Thread.Sleep(1000);
                        break;

                    case '5':
                        figure.list.Add(new polygon());
                        Console.WriteLine("многоугольник добавлен");
                        Thread.Sleep(1000);
                        break;

                    case '6':
                        figure.printAll(color);
                        _getch();
                        break;

                    case '0':
                        go_on = false;
                        break;

                    default:
                        Console.WriteLine("Неверный выбор");
                        Thread.Sleep(1000);
                        break;
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Неверный ввод Завершение программы");
                Environment.Exit(0);
            }
        }
Пример #3
0
 public virtual void printAll(colorDelegate color)
 {
     Console.ForegroundColor = ConsoleColor.Green;
 }