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); } }
static void Main(string[] args) { TemperatureSensor monitor = new TemperatureSensor(); TemperatureReporter reporter = new TemperatureReporter(); reporter.StartReporting(monitor); monitor.Notify(); }
static void Main(string[] args) { TemperatureSensor sensor = new TemperatureSensor(); TemperatureReporter reporter = new TemperatureReporter(); reporter.StartReporting(sensor); sensor.GetTemperature(); }
public static void Main(string[] args) { TemperatureReporter tempRep = new TemperatureReporter(); //Observador TemperatureMonitor tempMon = new TemperatureMonitor(); //Proveedor tempRep.Subscribe(tempMon); tempMon.GetTemperature(); }
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(); }
static void Main(string[] args) { TemperatureSensor monitor = new TemperatureSensor(); TemperatureReporter reporter = new TemperatureReporter(); monitor.Subscribe(reporter); reporter.StartReporting(); monitor.GetTemperature(); }