001package headfirst.combining.observer;
002
003public class QuackCounter implements Quackable {
004        Quackable duck;
005        static int numberOfQuacks;
006
007        public QuackCounter(Quackable duck) {
008                this.duck = duck;
009        }
010
011        public void quack() {
012                duck.quack();
013                numberOfQuacks++;
014        }
015
016        public static int getQuacks() {
017                return numberOfQuacks;
018        }
019
020        public void registerObserver(Observer observer) {
021                duck.registerObserver(observer);
022        }
023
024        public void notifyObservers() {
025                duck.notifyObservers();
026        }
027
028        public String toString() {
029                return duck.toString();
030        }
031}