001package headfirst.adapter.ducks;
002import java.util.Random;
003
004public class DuckAdapter implements Turkey {
005        Duck duck;
006        Random rand;
007
008        public DuckAdapter(Duck duck) {
009                this.duck = duck;
010                rand = new Random();
011        }
012
013        public void gobble() {
014                duck.quack();
015        }
016
017        public void fly() {
018                if (rand.nextInt(5)  == 0) {
019                        duck.fly();
020                }
021        }
022}