static void Main(string[] args) { Console.WriteLine("Enter file type:\n1.XML\n2.DOC\n3.TXT"); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: var xmlhandler = new XMLHandler(); xmlhandler.Open(); xmlhandler.Create(); xmlhandler.Change(); xmlhandler.Save(); break; case 2: var dochandler = new DOCHandler(); dochandler.Open(); dochandler.Create(); dochandler.Change(); dochandler.Save(); break; case 3: var txthandler = new TXTHandler(); txthandler.Open(); txthandler.Create(); txthandler.Change(); txthandler.Save(); break; default: break; } }
static void Main(string[] args) { Console.WriteLine("Input type of file (XML, TXT or DOC): "); string file = Console.ReadLine(); AbstractHandler handler = null; switch (file) { case "XML": handler = new XMLHandler(); break; case "TXT": handler = new TXTHandler(); break; case "DOC": handler = new DOCHandler(); break; default: Console.WriteLine("Unknown file format"); break; } if (handler != null) { handler.Create(); handler.Open(); handler.Change(); handler.Save(); } Console.ReadKey(); }