Consider the following TemperatureSensor class.  Which of th…

Written by Anonymous on May 16, 2026 in Uncategorized with no comments.

Questions

Cоnsider the fоllоwing TemperаtureSensor clаss.  Which of the following design pаttern is used in the TemperatureSensor class? Assume that TemperatureStation class has been designed and implemented correctly. public class TemperatureSensor {     private List weatherStations = new ArrayList();    private String temperature;      public void addTemperatureStation(TemperatureStation station) {        weatherStations.add(station);    }     public void removeTemperatureStation(TemperatureStation station) {        weatherStations.remove(station);    }     public void notifyStations() {        for (TemperatureStation station : weatherStations) {            station.update(temperature);        }    }     public void setTemperature(String currentTemp) {        this.temperature = currentTemp;        notifyStations();    }}

Comments are closed.