zoukankan      html  css  js  c++  java
  • 观察者模式

    interface ISubject
    {
        void registerInterest(IObserver ob);
    }
    interface IObserver
    {
        void Update();
    }
    public class Subject : ISubject
    {
        ArrayList al = new ArrayList();
    
        public void registerInterest(IObserver ob)
        {
              al.Add(ob);
         }
    
         void sendNotify()
         {
                foreach(IObserver ob in al)
                {
                      ob.Update();
                 }
          }
    
         void xxxxxxxxxxx()
         {
                sendNotify();
          }
    }
    public class AObserver
    {
        public void Update()
        {
    
         }
    }
    
    public class BObserver
    {
        public void Update()
        {
    
         }
    }
    public static void Main()
    {
           .......
    
    }
  • 相关阅读:
    day58
    day57
    day55
    day56
    day54
    Vue(练习二)
    Vue练习
    Vue框架
    作业
    Django(九)
  • 原文地址:https://www.cnblogs.com/yasepix/p/5006738.html
Copyright © 2011-2022 走看看