001package headfirst.combining.composite; 002 003import java.util.ArrayList; 004 005public class Flock implements Quackable { 006 ArrayList<Quackable> quackers = new ArrayList<Quackable>(); 007 008 public void add(Quackable quacker) { 009 quackers.add(quacker); 010 } 011 012 public void quack() { 013 for (Quackable quacker : quackers) { 014 quacker.quack(); 015 } 016 } 017 018 public String toString() { 019 return "Flock of Quackers"; 020 } 021}