public void Unsubscribe(TemperatureReporter observer)
 {
     if (observers.Contains(observer))
     {
         this.observers.Remove(observer);
     }
 }
 public void Subscribe(TemperatureReporter observer)
 {
     if (!observers.Contains(observer))
     {
         observers.Add(observer);
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            TemperatureSensor   monitor  = new TemperatureSensor();
            TemperatureReporter reporter = new TemperatureReporter();

            reporter.StartReporting(monitor);
            monitor.Notify();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            TemperatureSensor   sensor   = new TemperatureSensor();
            TemperatureReporter reporter = new TemperatureReporter();

            reporter.StartReporting(sensor);
            sensor.GetTemperature();
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            TemperatureReporter tempRep = new TemperatureReporter(); //Observador
            TemperatureMonitor  tempMon = new TemperatureMonitor();  //Proveedor

            tempRep.Subscribe(tempMon);
            tempMon.GetTemperature();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            TemperatureSensor   sensor    = new TemperatureSensor();
            TemperatureReporter reporter  = new TemperatureReporter();
            DateTime            localDate = DateTime.Now;
            Temperature         a         = new Temperature(20, localDate);;

            sensor.GetTemperature();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            TemperatureSensor   monitor  = new TemperatureSensor();
            TemperatureReporter reporter = new TemperatureReporter();

            monitor.Subscribe(reporter);
            reporter.StartReporting();
            monitor.GetTemperature();
        }