Exemplo n.º 1
0
        static void Main(string[] args)
        {
            DOCHandler docFile = new DOCHandler();

            docFile.Create();
            docFile.Change();
            docFile.Open();
            docFile.Save();
            Console.WriteLine(new string('-', 20));

            TXTHandler txtFile = new TXTHandler();

            txtFile.Create();
            txtFile.Change();
            txtFile.Open();
            txtFile.Save();
            Console.WriteLine(new string('-', 20));

            XMLHandler xmlFile = new XMLHandler();

            xmlFile.Create();
            xmlFile.Change();
            xmlFile.Open();
            xmlFile.Save();
            Console.WriteLine(new string('-', 20));

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            AbstractHandler xml_file = new XMLHandler();

            xml_file.Create();
            xml_file.Open();
            xml_file.Change();
            xml_file.Save();

            AbstractHandler txt_file = new TXTHandler();

            txt_file.Create();
            txt_file.Open();
            txt_file.Change();
            txt_file.Save();

            AbstractHandler doc_file = new DOCHandler();

            doc_file.Create();
            doc_file.Open();
            doc_file.Change();
            doc_file.Save();

            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main()
        {
            AbstractHandler xmlDocument = new XMLHandler();

            Console.WriteLine("Вы выбрали работу с документом типа XML:");
            xmlDocument.Create();
            xmlDocument.Open();
            xmlDocument.Change();
            xmlDocument.Save();
            Console.WriteLine("\n");

            AbstractHandler txtDocument = new TXTHandler();

            Console.WriteLine("Вы выбрали работу с документом типа TXT:");
            txtDocument.Create();
            txtDocument.Open();
            txtDocument.Change();
            txtDocument.Save();
            Console.WriteLine("\n");

            AbstractHandler docDocument = new DOCHandler();

            Console.WriteLine("Вы выбрали работу с документом типа DOC:");
            docDocument.Create();
            txtDocument.Open();
            docDocument.Change();
            docDocument.Save();

            // Delay
            Console.ReadKey();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            AbstractHandler XMLhandler = new XMLHandler();

            XMLhandler.Show();
            AbstractHandler TXThandler = new TXTHandler();

            TXThandler.Show();
            AbstractHandler DOChandler = new DOCHandler();

            DOChandler.Show();
        }
Exemplo n.º 5
0
        public void DoSomething()
        {
            AbstractHandler handler;
            string          doctype;

            Console.WriteLine("Chose document type");
            doctype = Console.ReadLine();
            switch (doctype)
            {
            case "xml":
            case "XML":
            {
                handler = new XMLHandler();
                break;
            }

            case "txt":
            case "TXT":
            {
                handler = new TXTHandler();
                break;
            }

            case "doc":
            case "DOC":
            {
                handler = new DOCHandler();
                break;
            }

            default:
            {
                handler = null;
                Console.WriteLine("Wrong document type");
                break;
            }
            }

            if (handler != null)
            {
                handler.Open();
                handler.Create();
                handler.Change();
                handler.Save();
            }

            Console.ReadKey();
        }
Exemplo n.º 6
0
        public void DoSomething()
        {
            AbstractHandler handler;
            string doctype;
            Console.WriteLine("Chose document type");
            doctype = Console.ReadLine();
            switch (doctype)
            {
                case "xml":
                case "XML":
                    {
                        handler = new XMLHandler();
                        break;
                    }
                case "txt":
                case "TXT":
                    {
                        handler = new TXTHandler();
                        break;
                    }
                case "doc":
                case "DOC":
                    {
                        handler = new DOCHandler();
                        break;
                    }
                default:
                    {
                        handler = null;
                        Console.WriteLine("Wrong document type");
                        break;
                    }
            }

            if (handler != null)
            {
                handler.Open();
                handler.Create();
                handler.Change();
                handler.Save();
            }

            Console.ReadKey();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            string          format;
            AbstractHandler @object = null;

Aaa:
            Console.Write("Please input file format (XML, TXT, DOC): ");
            bool t = false;

            do
            {
                format = Console.ReadLine();
                switch (format)
                {
                case "XML":
                {
                    @object = new XMLHandler();
                    t       = true;
                    break;
                }

                case "TXT":
                {
                    @object = new TXTHandler();
                    t       = true;
                    break;
                }

                case "DOC":
                {
                    @object = new DOCHandler();
                    t       = true;
                    break;
                }

                default:
                {
                    Console.WriteLine("Wrong format! Please input again (XML, TXT, DOC)");
                    t = false;
                    break;
                }
                }
            } while (!t);

            Console.WriteLine("\nYou are selected {0} format", format);
            Console.WriteLine("\nYou can. open {0} file, creat {0} file, change {0} file and save {0} file", format);
            Console.Write("Please input your operation type. open | creat | chenge | save | exit for exit: ");

            do
            {
                string operation = Console.ReadLine();
                switch (operation)
                {
                case "open":
                {
                    @object.Open();
                    break;
                }

                case "create":
                {
                    @object.Create();
                    break;
                }

                case "change":
                {
                    @object.Change();
                    break;
                }

                case "save":
                {
                    @object.Save();
                    break;
                }

                case "exit":
                {
                    t = false;
                    break;
                }

                case "change format":
                {
                    goto Aaa;
                }

                default:
                {
                    Console.WriteLine("Wrong operation! Please input again. (open, create, change, save)");
                    t = true;
                    break;
                }
                }
                Console.WriteLine("If you want to change format type input (change format) ");
            } while (t);
        }