Пример #1
0
        /// <summary>
        /// A.L2.P1/1. Создать консольное приложение, которое может выводить
        /// на печатать введенный текст  одним из трех способов:
        /// консоль, файл, картинка.
        /// </summary>
        public static void A_L2_P1_1()
        {
            Console.WriteLine("Введите текст ");
            string text = Console.ReadLine();

            Console.WriteLine("Choose print tupe : ");
            Console.WriteLine("1-console : ");
            Console.WriteLine("2-file : ");
            Console.WriteLine("3-picture : ");
            string type = Console.ReadLine();

            IPrinter printer = null;


            switch (type)
            {
            case "1":
                var printer1 = new ConsolePrinter(ConsoleColor.Blue);
                printer1.Print(text);
                break;

            case "2":
                var printer2 = new FilePrinter("test");
                printer2.Print(text);
                break;

            case "3":
                var printer3 = new BitmapPrinter("BitmapPrinerExample");
                printer3.Print(text);
                Console.WriteLine("You have choosen printing  into picture ");
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// A.L2.P1/1. Создать консольное приложение, которое может выводить
        /// на печатать введенный текст  одним из трех способов:
        /// консоль, файл, картинка.
        /// </summary>
        public static void A_L2_P1_1()
        {
            Console.WriteLine("Choose print type:");
            Console.WriteLine("1 - Console");
            Console.WriteLine("2 - File");
            Console.WriteLine("3 - Image");

            string type = Console.ReadLine();

            IPrinter printer = null;

            switch (type)
            {
            case "1":
                printer = new ConsolePrinter(ConsoleColor.Blue);
                break;

            case "2":
                printer = new FilePrinter("test");
                break;

            case "3":
                printer = new BitmapPrinter("BitmapPrinerExample");
                Console.WriteLine("You have chosen printing into image");
                break;
            }

            Console.WriteLine("Write text");

            for (int i = 0; i < 5; i++)
            {
                var text = Console.ReadLine();
                printer?.Print(text);
            }
        }
Пример #3
0
        /// <summary>
        /// AL3-P2/3. Отредактировать консольное приложение Printer.
        /// Заменить базовый абстрактный класс на интерфейс.
        /// </summary>
        public static void AL3_P2_3()
        {
            Console.WriteLine(" Choose print type: ");
            Console.WriteLine("1 - Console");
            Console.WriteLine("2 - File");
            Console.WriteLine("3 - Image");
            Console.Write(">> ");
            var      type    = Console.ReadLine();
            IPrinter printer = null;

            switch (type)
            {
            case "1":
            {
                printer = new ConsolePrinter(ConsoleColor.DarkBlue);
                //printer.Print();
                //Console.WriteLine("You have chosen printing into console");
                break;
            }

            case "2":
            {
                printer = new FilePrinter("PrintingText");
                //printer.Print();
                //Console.WriteLine("You have chosen printing into file");
                break;
            }

            case "3":
            {
                printer = new BitmapPrinter("testImage");
                //printer.Print(Console);
                //Console.WriteLine("You have chosen printing into image");
                break;
            }
            }
            Console.WriteLine("Write text");
            for (int i = 0; i < 1; i++)
            {
                Console.Write(">> ");
                printer.Print(Console.ReadLine());
                //printer.Print();
            }
        }