Exemplo n.º 1
0
        static void Main()
        {
            TrainSignal trainSignal = new TrainSignal();

            new Car(trainSignal);
            new Car(trainSignal);
            new Car(trainSignal);
            trainSignal.HereComesATrain();
        }
Exemplo n.º 2
0
 public Car(TrainSignal trainSignal)
 {
     // We are observing the trainSignal
     // When something happens, the trainSignal notifies us via the StopTheCar method
     trainSignal.TrainIsComing += StopTheCar;
 }