package class2_1_DuckStrategies_v7_Factory.ducks; import class2_1_DuckStrategies_v7_Factory.StandardQuacking; import class2_1_DuckStrategies_v7_Factory.StandardSwimming; import java.awt.Point; /** * This class represents a specialized type of Duck * @author hornick */ public class Mallard extends Duck { /** * Mallard-specific constructor */ public Mallard(String name) { super(name, "mallard.jpg"); this.setBehaviors(new StandardSwimming(this), new StandardQuacking(this)); // this value defines how far a Mallard moves each update period - s random value between 3 and 8. increment = new Point(random.nextInt(3)+5, random.nextInt(3)+5 ); //Note that the duck's image and incremental movements could potentially be parameterized // as constructor call arguments, but this would increase the coupling between this class and the // class invoking the constructor, since the invoking class would then have to know more about // the inherent behavior of each type of duck created. } }