Exemple #1
0
        public static void Scenario2()
        {
            ElectricBulb bulb = new ElectricBulb();

            bulb.OnStateChanged += (sender, args) => Console.WriteLine("State changed");
            ExecuteStandardSequence(bulb);
        }
Exemple #2
0
 private static void ExecuteStandardSequence(ElectricBulb bulb)
 {
     bulb.ReportStatus();
     bulb.SwitchOn();
     bulb.ReportStatus();
     bulb.SwitchOff();
     bulb.ReportStatus();
     bulb.SwitchOff();
     bulb.ReportStatus();
     bulb.SwitchOn();
     bulb.ReportStatus();
     bulb.SwitchOn();
     bulb.ReportStatus();
 }
Exemple #3
0
 public void SwitchOff(ElectricBulb bulb)
 {
     Console.WriteLine("The bulb is already off!!!");
 }
Exemple #4
0
 public void SwitchOn(ElectricBulb bulb)
 {
     Console.WriteLine("Switching On");
     bulb.State = new ElectricBulbOnState();
     bulb.RaiseOnStateChanged();
 }