static void Main(string[] args) { IEstadoAlarma InicialState = new AlarmaActivada(); entAlarma = new Alarma.Alarma(InicialState); ActivarDesactivarAlarma(); }
static void Main(string[] args) { var EstadoInicial = new AlarmaActivada(); var context = new Alarma(EstadoInicial); EstadoInicial.SetContext(context); Console.WriteLine("-----<Activando alarma>-------"); context.Activar(); Console.WriteLine("-----<Desactivando alarma>----"); Thread.Sleep(2000); context.Desactivar(); Console.WriteLine("-----<Desactivando alarma>----"); Thread.Sleep(2000); context.Desactivar(); Console.WriteLine("-----<Activando alarma>-------"); Thread.Sleep(2000); context.Activar(); Console.ReadKey(); }