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

class WeatherAPP2(Observer, Display):
    def __init__(self, subject: Subject) -> None:
        super().__init__()
        self.humidity: float = 0
        self.subject = subject

    def display(self):
        '''显示天气信息'''
        print("="*10)
        print("天气APP2")
        print("现在的湿度{:.2f}".format(self.humidity))
        rainHint: str = ""
        if self.humidity > 10:
            rainHint = "可能要下雨了，请带上雨具"
        else:
            rainHint = "不会下雨，放心出去浪吧"
        print("下雨提示：{}".format(rainHint))
        print("="*10)

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