void TestObserver() { Secretary newSecretary = new Secretary(); StockObserver stockGuy = new StockObserver("Stock Guy", newSecretary); NBAObserver nbaGuy = new NBAObserver("NBA Guy", newSecretary); newSecretary.Attach(stockGuy); newSecretary.Attach(nbaGuy); newSecretary.DeTach(stockGuy); newSecretary.Nofity(); }
static void Main(string[] args) { Secretary Marry = new Secretary(); stockObserver Marry1 = new stockObserver("瑪莉", Marry); stockObserver Marry2 = new stockObserver("強尼", Marry); Marry.Attach(Marry1); Marry.Attach(Marry2); Marry.SecretaryAction = "老闆回來了"; Marry.Notify(); Console.Read(); }