static void Main(string[] args) { //前臺小姐童子喆 Secretary tongzizhe = new Secretary(); //看股票的同事 StockObserver tongshi1 = new StockObserver("魏關奼", tongzizhe); StockObserver tongshi2 = new StockObserver("易管查", tongzizhe); //前臺記下了兩位同事 tongzizhe.Attach(tongshi1); tongzizhe.Attach(tongshi2); //發現老闆回來 tongzizhe.SecretaryAction = "老闆回來了!"; //通知兩個同事 tongzizhe.Notify(); Console.Read(); }
public NBAObserver(string name, Secretary sub) : base(name, sub) { }
public StockObserver(string name, Secretary sub) : base(name, sub) { }
public Observer(string name, Secretary sub) { this.name = name; this.sub = sub; }