Exemplo n.º 1
0
        static void ObserverDemo()
        {
            Speedometer  speedometer = new Speedometer();
            SpeedMonitor monitor     = new SpeedMonitor(mySpeedoMeter);
            Gearbox      gear        = new Gearbox(mySpeedoMeter);

            mySpeedoMeter.CurrentSpeed = 10;
            mySpeedoMeter.CurrentSpeed = 15;
            mySpeedoMeter.CurrentSpeed = 20;
            mySpeedoMeter.CurrentSpeed = 27;
            mySpeedoMeter.CurrentSpeed = 32;
        }
Exemplo n.º 2
0
        private static void ObserverPatternDemo()
        {
            Speedometer  mySpeedometer = new Speedometer();
            SpeedMonitor monitor       = new SpeedMonitor(mySpeedometer);
            Gearbox      gearbox       = new Gearbox(mySpeedometer);

            mySpeedometer.CurrentSpeed = 10;
            mySpeedometer.CurrentSpeed = 20;
            mySpeedometer.CurrentSpeed = 25;
            mySpeedometer.CurrentSpeed = 30;
            mySpeedometer.CurrentSpeed = 35;
        }
Exemplo n.º 3
0
        private static void ObserverPatternDemo()
        {
            Speedometer  mySpeedometer = new Speedometer();
            SpeedMonitor monitor       = new SpeedMonitor(mySpeedometer);
            GearBox      gearbox       = new GearBox(mySpeedometer);

            //Set current speed property to a value
            mySpeedometer.CurrentSpeed = 10;
            mySpeedometer.CurrentSpeed = 20;
            mySpeedometer.CurrentSpeed = 25;
            mySpeedometer.CurrentSpeed = 30;
            mySpeedometer.CurrentSpeed = 35;
        }
Exemplo n.º 4
0
 public Gearbox(Speedometer speed)
 {
     speed.ValueChanged += ValueHasChanged;
 }