예제 #1
0
        public void RegisterObserver(IObserver observer)
        {
            DuckIterator iterator = new DuckIterator(ducks);

            while (iterator.HasNext())
            {
                IQuackable duck = (IQuackable)iterator.Next();
                duck.RegisterObserver(observer);
            }
        }
예제 #2
0
        public void NotifyObservers()
        {
            DuckIterator iterator = new DuckIterator(observers);

            while (iterator.HasNext())
            {
                IObserver observer = (IObserver)iterator.Next();
                observer.Update(duck);
            }
        }
예제 #3
0
        public void Quack()
        {
            DuckIterator iterator = new DuckIterator(ducks);

            while (iterator.HasNext())
            {
                IQuackable quacker = (IQuackable)iterator.Next();
                quacker.Quack();
            }
        }