예제 #1
0
        static void Main()
        {
            Console.WriteLine("Введите ключ");
            string         key = Console.ReadLine();
            DocumentWorker doc = null; //Создание екземпляра класса DocumentWorker

            switch (key)
            {
            case "prof": doc = new ProDocumentWorker();     //Приведение экземпляра производного класса к базовому типу UpCast.
                break;

            case "expert": doc = new ExpertDocumentWorker();
                break;

            default: Console.WriteLine("Ключ неверен");
                doc = new DocumentWorker();
                break;
            }

            doc.OpenDocument(); //вызов метода OpenDocument на экземпляре doc класса
            doc.EditDocument();
            doc.SaveDocument();

            Console.ReadKey();
        }
예제 #2
0
        static void Main()
        {
            Console.WriteLine("Введите ключ");
            string         key = Console.ReadLine();
            DocumentWorker doc = null;

            switch (key)
            {
            case "prof": doc = new ProDocumentWorker();
                break;

            case "expert": doc = new ExpertDocumentWorker();
                break;

            default: Console.WriteLine("Ключ неверен");
                doc = new DocumentWorker();
                break;
            }

            doc.OpenDocument();
            doc.EditDocument();
            doc.SaveDocument();

            Console.ReadKey();
        }
예제 #3
0
 static void WorkWithDocument(DocumentWorker document, string objectName)
 {
     Console.WriteLine(new string('.', 10));
     Console.WriteLine("------- {0} ------", objectName);
     document.OpenDocument();
     document.EditDocument();
     document.SaveDocument();
 }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("[keys: pro, exp]");
            Console.Write("Введите ключ PRO: ");
            string pro = Console.ReadLine();

            Console.Write("Введите ключ EXPERT: ");
            string         expert   = Console.ReadLine();
            DocumentWorker document = CreateDocumentWorker(pro, expert);

            Console.WriteLine("open: ");
            document.OpenDocument();

            Console.WriteLine("edit: ");
            document.EditDocument();

            Console.WriteLine("save: ");
            document.SaveDocument();
            Console.ReadKey();
        }
예제 #5
0
파일: Program.cs 프로젝트: UomaShu/ISDdz
        static void Main(string[] args)
        {
            string key;
            int    choice;
            bool   flag = true;

            Console.WriteLine("Введите ключ (если не имеете ключа просто нажмите Enter):");
            key = Console.ReadLine();
            switch (key)
            {
            case "":
                DocumentWorker documentLite = new DocumentWorker();
                Console.WriteLine("Добро пожаловать в Lite версию!");
                Menu();
                while (flag)
                {
                    choice = int.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        documentLite.OpenDocument();
                        break;

                    case 2:
                        documentLite.EditDocument();
                        break;

                    case 3:
                        documentLite.SaveDocument();
                        break;

                    case 4:
                        flag = false;
                        break;
                    }
                }
                break;

            case "pro":
                DocumentWorker documentPro = new ProDocumentWorker();
                Console.WriteLine("Добро пожаловать в Pro версию!");
                Menu();
                while (flag)
                {
                    choice = int.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        documentPro.OpenDocument();
                        break;

                    case 2:
                        documentPro.EditDocument();
                        break;

                    case 3:
                        documentPro.SaveDocument();
                        break;

                    case 4:
                        flag = false;
                        break;
                    }
                }
                break;

            case "exp":
                DocumentWorker documentExp = new ExpertDocumentWorker();
                Console.WriteLine("Добро пожаловать в Expert версию!");
                Menu();
                while (flag)
                {
                    choice = int.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        documentExp.OpenDocument();
                        break;

                    case 2:
                        documentExp.EditDocument();
                        break;

                    case 3:
                        documentExp.SaveDocument();
                        break;

                    case 4:
                        flag = false;
                        break;
                    }
                }
                break;

            default:
                Console.WriteLine("Неверный ввод!");
                break;
            }
            Console.ReadKey();
        }