public void RegisterObserver(IObserver observer) { DuckIterator iterator = new DuckIterator(ducks); while (iterator.HasNext()) { IQuackable duck = (IQuackable)iterator.Next(); duck.RegisterObserver(observer); } }
public void NotifyObservers() { DuckIterator iterator = new DuckIterator(observers); while (iterator.HasNext()) { IObserver observer = (IObserver)iterator.Next(); observer.Update(duck); } }
public void Quack() { DuckIterator iterator = new DuckIterator(ducks); while (iterator.HasNext()) { IQuackable quacker = (IQuackable)iterator.Next(); quacker.Quack(); } }