001package headfirst.combining.observer;
002
003import java.util.ArrayList;
004
005public class Flock implements Quackable {
006        ArrayList<Quackable> ducks = new ArrayList<Quackable>();
007
008        public void add(Quackable duck) {
009                ducks.add(duck);
010        }
011
012        public void quack() {
013                for (Quackable duck : ducks) {
014                        duck.quack();
015                }
016        }
017
018        public void registerObserver(Observer observer) {
019                for (Quackable duck : ducks) {
020                        duck.registerObserver(observer);
021                }
022        }
023
024        public void notifyObservers() { }
025
026        public String toString() {
027                return "Flock of Ducks";
028        }
029}