class CurrentCondition(Observer, Display): def __init__(self): self.data = Data() def update(self, data): self.data = data def display(self): print(self.data.print_display())
class ThirdParty(Observer, Display): def __init__(self): self.data = Data() def update(self, data): self.data = data def display(self): print(self.data.print_display())
class Forecast(Observer, Display): def __init__(self): self.data_forecast = Data() def update(self, data): self.data_forecast = self.get_forecast(data) def display(self): print(self.data_forecast.print_display()) def get_forecast(self, data): # какие-то действия, которые расчитывают статистику по полученным данным return data
def __init__(self): self.data = Data()
def __init__(self): self.list_observer = [] self.data = Data() self.measurements_changed()
def __init__(self): self.data_forecast = Data()
from base.subject import Subject from weather_data.weather_data import WeatherData from element_display.current_condition import CurrentCondition from weather_data.data import Data if __name__ == '__main__': data = Data() wd = WeatherData() x = CurrentCondition() wd.register_observer(x) x.display() wd.measurements_changed() x.display()
def __init__(self): self.data_stat = Data()