Exemple #1
0
        public Form1()
        {
            InitializeComponent();

            speedMonitorSubject = new SpeedMonitorSubject();    // must create SpeedMonitorSubject first - we need to pass
                                                                // it in when we call an observer's constructor
            rpmObserver        = new RPMObserver(lblRPM, speedMonitorSubject);
            caloriesObserver   = new CaloriesObserver(lblCaloriesPerHour, speedMonitorSubject);
            kmsPerHourObserver = new KMsPerHourObserver(lblKMPerHour, speedMonitorSubject);
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();

            speedMonitorSubject = new SpeedMonitorSubject();    // must create SpeedMonitorSubject first - we need to pass
                                                                // it in when we call an observer's constructor
            rpmObserver = new RPMObserver(lblRPM, speedMonitorSubject);
            caloriesObserver = new CaloriesObserver(lblCaloriesPerHour, speedMonitorSubject);
            kmsPerHourObserver = new KMsPerHourObserver(lblKMPerHour, speedMonitorSubject);
        }
Exemple #3
0
        public BicycleObserver(Label displayLabel, SpeedMonitorSubject bikeSubject)
        {
            this.displayLabel = displayLabel;

            currentRPM           = 0;
            currentComputedValue = 0;
            this.bikeSubject     = bikeSubject;

            // VERY IMPORTANT. Observers sign themselves up....
            bikeSubject.AddObserver(this);
        }
        public BicycleObserver(Label displayLabel, SpeedMonitorSubject bikeSubject)
        {
            this.displayLabel = displayLabel;

            currentRPM = 0;
            currentComputedValue = 0;
            this.bikeSubject = bikeSubject;

            // VERY IMPORTANT. Observers sign themselves up....
            bikeSubject.AddObserver(this);
        }
Exemple #5
0
 public KMsPerHourObserver(Label label, SpeedMonitorSubject bikeSubject) : base(label, bikeSubject)
 {
     // Nothing...
 }
 public KMsPerHourObserver(Label label, SpeedMonitorSubject bikeSubject)
     : base(label, bikeSubject)
 {
     // Nothing...
 }
 public CaloriesObserver(Label label, SpeedMonitorSubject bikeSubject)
     : base(label, bikeSubject)
 {
     //  nothing -- just use parent const.
 }
 public CaloriesObserver(Label label, SpeedMonitorSubject bikeSubject) : base(label, bikeSubject)
 {
     //  nothing -- just use parent const.
 }
 public RPMObserver(Label label, SpeedMonitorSubject bikeSubject)
     : base(label, bikeSubject)
 {
 }
 public RPMObserver(Label label, SpeedMonitorSubject bikeSubject) : base(label, bikeSubject)
 {
 }