Пример #1
0
        // Use this for initialization
        void Start()
        {
            //WeatherStation sw = new WeatherStation();
            //BillboardA a = new BillboardA();
            //BillboardB b = new BillboardB();
            //BillboardC c = new BillboardC();
            //sw.Update(a,b,c);
            ConcreteSubject1  sub1 = new ConcreteSubject1();
            ConcreteObserver1 ob1  = new ConcreteObserver1(sub1);

            sub1.RegisterObserver(ob1);

            ConcreteObserver2 ob2 = new ConcreteObserver2(sub1);

            sub1.RegisterObserver(ob2);

            sub1.SubjectState = "温度 90";
        }
Пример #2
0
 public ConcreteObserver2(ConcreteSubject1 subject)
 {
     mSubject = subject;
 }