Beispiel #1
0
        static void Main(string[] args)
        {
            //ex1
            var  lightbulb = new LightBulb();
            var  switch1   = new Switch();
            Flip flip      = switch1.Flip(lightbulb);

            flip();
            flip();

            //ex2
            var switch2 = new Switch();
        }
Beispiel #2
0
 public void Flip(LightBulb lightBulb)
 {
     lightBulb.IsOn = !lightBulb.IsOn;
     IsOn           = !IsOn;
     if (IsOn)
     {
         Console.WriteLine("The lightbulb switches on.");
     }
     if (!IsOn)
     {
         Console.WriteLine("The lightbulb switches off.");
     }
 }