static void Main(string[] args) { while (true) { Console.WriteLine("Escolha uma opção:"); Console.WriteLine(""); Console.WriteLine("1: Abstract Factory:"); Console.WriteLine("2: Factory Method:"); Console.WriteLine("3: Singleton:"); Console.WriteLine("------------------------"); Console.WriteLine("4: Adapter:"); Console.WriteLine("5: Facade:"); Console.WriteLine("1: Composite:"); Console.WriteLine("------------------------"); Console.WriteLine("7: Command:"); Console.WriteLine("8: Observer:"); Console.WriteLine("9: Strategy:"); var key = Console.ReadKey(); switch (key.KeyChar) { case '1': ExecucaoAbstractFactory.Executar(); break; case '2': ExecucaoFactoryMethod.Executar(); break; case '3': ExecucaoSingleton.Executar(); break; case '4': ExecucaoAdapter.Executar(); break; case '\u001b': Environment.Exit(0); break; default: continue; } } }
private static void Main() { Console.WriteLine("Escolha a operação:"); Console.WriteLine("------------------------"); Console.WriteLine("Creational Patterns"); Console.WriteLine("------------------------"); Console.WriteLine("1 - Abstract Factory"); Console.WriteLine("2 - Method Factory"); Console.WriteLine("3 - Singleton"); Console.WriteLine("------------------------"); Console.WriteLine("Structural Patterns"); Console.WriteLine("------------------------"); Console.WriteLine("4 - Adapter"); Console.WriteLine("5 - Facade"); Console.WriteLine("6 - Composite"); Console.WriteLine("------------------------"); Console.WriteLine("Behavioral Patterns"); Console.WriteLine("------------------------"); Console.WriteLine("7 - Command"); Console.WriteLine("8 - Strategy"); Console.WriteLine("9 - Observer"); Console.WriteLine("------------------------"); Console.WriteLine("Finalizar a Aplicação"); Console.WriteLine("------------------------"); Console.WriteLine("0 - Sair"); Console.WriteLine("------------------------"); var opcao = Console.ReadKey(); Console.WriteLine(""); Console.WriteLine("------------------------"); Console.WriteLine(""); switch (opcao.KeyChar) { case '1': ExecucaoAbstractFactory.Executar(); break; case '2': ExecucaoFactoryMethod.Executar(); break; case '3': ExecucaoSingleton.Executar(); break; case '4': ExecucaoAdapter.Executar(); break; case '5': ExecucaoFacade.Executar(); break; case '6': ExecucaoComposite.Executar(); break; case '7': ExecucaoCommand.Executar(); break; case '8': ExecucaoStrategy.Executar(); break; case '9': ExecucaoObserver.Executar(); break; case '0': Environment.Exit(0); break; } Console.ReadKey(); Console.Clear(); Main(); }