//Создайте класс DocumentWorker. //В теле класса создайте три метода OpenDocument(), EditDocument(), SaveDocument(). //В тело каждого из методов добавьте вывод на экран соответствующих строк: "Документ открыт", "Редактирование документа доступно в версии Про", "Сохранение документа доступно в версии Про". //Создайте производный класс ProDocumentWorker. //Переопределите соответствующие методы, при переопределении методов выводите следующие строки: "Документ отредактирован", "Документ сохранен в старом формате, сохранение в остальных форматах доступно в версии Эксперт". //Создайте производный класс ExpertDocumentWorker от базового класса ProDocumentWorker. Переопределите соответствующий метод.При вызове данного метода необходимо выводить на экран "Документ сохранен в новом формате". //В теле метода Main() реализуйте возможность приема от пользователя номера ключа доступа pro и exp.Если пользователь не вводит ключ, он может пользоваться только бесплатной версией(создается экземпляр базового класса), //если пользователь ввел номера ключа доступа pro и exp, то должен создаться экземпляр соответствующей версии класса, приведенный к базовому - DocumentWorker. static void Main() { const string proKey = "pro"; const string expertKey = "expert"; DocumentWorker documentWorker; Console.WriteLine("Enter your key:"); string inputKey = Console.ReadLine(); if (inputKey == proKey) { documentWorker = new ProDocumentWorker(); } else if (inputKey == expertKey) { documentWorker = new ExpertDocumentWorker(); } else { documentWorker = new DocumentWorker(); } documentWorker.OpenDocument(); documentWorker.EditDocument(); documentWorker.SaveDocument(); Console.ReadLine(); }
static void Main(string[] args) { DocumentWorker freeversion = new DocumentWorker(); freeversion.OpenDocument(); freeversion.EditDocument(); freeversion.SaveDocument(); Console.WriteLine("Вы пользуетесь бесплатной версией продукта, если хотите пользоваться версией Pro или Expert" + "введите соответствующий ключ : pro или expert "); string choice = Console.ReadLine(); if (choice == "pro") { DocumentWorker proversion = new ProDocumentWorker(); proversion.OpenDocument(); proversion.EditDocument(); proversion.SaveDocument(); } else if (choice == "expert") { ProDocumentWorker expertversion = new ExpertDocumentWorker(); expertversion.OpenDocument(); expertversion.EditDocument(); expertversion.SaveDocument(); } }
static void Main(string[] args) { DocumentWorker document; Console.WriteLine("Введите ключ: 0 - бесплатная версия, 1 - pro-версия, 2 - exp-версия. 9 - выход из программы"); int key = int.Parse(Console.ReadLine()); do { switch (key) { case 0: { document = new DocumentWorker(); document.openDocument(); document.editDocument(); document.saveDocument(); break; } case 1: { document = new ProDocumentWorker(); document.openDocument(); document.editDocument(); document.saveDocument(); break; } case 2: { document = new ExpertDocumentWorker(); document.openDocument(); document.saveDocument(); break; } default: { break; } } key = int.Parse(Console.ReadLine()); } while (key != 9); }
static void Main(string[] args) { DocumentWorker documentWorker = new DocumentWorker(); string ansver; Console.WriteLine("Enter key App or press ENTER."); ansver = Console.ReadLine(); if (String.Equals(ansver, "exp")) { documentWorker = new ExpertDocumentWorker(); } else if (String.Equals(ansver, "pro")) { documentWorker = new ProDocumentWorker(); } else { documentWorker = new DocumentWorker(); } documentWorker.OpenDocument(); documentWorker.EditDocument(); documentWorker.SaveDocument(); }
static void Main(string[] args) { const string proKey = "pro"; const string expKey = "exp"; Console.WriteLine("Введите лицензионный ключ!"); string key = Console.ReadLine(); DocumentWorker document = new DocumentWorker(); switch (key) { case proKey: document = new ProDocumentWorker(); break; case expKey: document = new ExpertDocumentWorker(); break; default: document = new DocumentWorker(); break; } Console.WriteLine("Введите команды для работы с документом: \n1-Открыть документ, \n2-Редактировать документ, \n3-Сохранить, \n4-выход"); bool b = true; while (b == true) { switch (Console.ReadLine()) { case "1": Console.ForegroundColor = ConsoleColor.Green; document.OpenDocument(); Console.ForegroundColor = ConsoleColor.White; break; case "2": Console.ForegroundColor = ConsoleColor.Green; document.EditDocument(); Console.ForegroundColor = ConsoleColor.White; break; case "3": Console.ForegroundColor = ConsoleColor.Green; document.SaveDocument(); Console.ForegroundColor = ConsoleColor.White; break; case "4": b = false; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Выход"); Console.ForegroundColor = ConsoleColor.White; break; default: Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Неправильная команда!"); Console.ForegroundColor = ConsoleColor.White; break; } } }