#######################################################
#
# WeatherAPP1.py
# Python implementation of the Class WeatherAPP1
# Generated by Enterprise Architect
# Created on:      13-6��-2021 18:19:09
# Original author: 70748
#
#######################################################
from .WeatherSDK import WeatherSDK
from .Subject import Subject
from .Observer import Observer
from .Display import Display
from .air_quality import AirQuality, show_air_quality_text


class WeatherAPP1(Observer, Display):
    def __init__(self) -> None:
        super().__init__()
        self.temperature: float = 0
        self.humidity: float = 0
        self.airQuality: AirQuality = AirQuality.NORMAL

    def display(self):
        '''显示天气信息'''
        print("="*10)
        print("天气APP1")
        print("现在的气温：{:.2f}摄氏度".format(self.temperature))
        print("现在的湿度{:.2f}".format(self.humidity))
        print("现在的空气质量{}".format(show_air_quality_text(self.airQuality)))
        print("="*10)

    def update(self, subject: Subject):
        if isinstance(subject, WeatherSDK):
            sdk: WeatherSDK = subject
            self.temperature = sdk.temperature
            self.humidity = sdk.humidity
            self.airQuality = sdk.airQuality
            self.display()
