package example2_1; import java.awt.Point; /** * Author: Josiah Yoder et al. * Class: SE1011-011 * Date: 12/9/13 7:45 AM * Lesson: Week 7, Day 1 */ public class Duck implements Movable { double topLeftX; double topLeftY; String name; SwimBehavior swimBehavior; public Duck(String name) { this.name = name; this.swimBehavior = new Floating(); } public Duck() { this("Anon."); } public Point getPosition() { return new Point((int)topLeftX, (int) topLeftY); } public void setSwimBehavior(SwimBehavior swimBehavior) { this.swimBehavior = swimBehavior; } public void setPosition(Point point) { topLeftX = point.getX(); topLeftY = point.getY(); } public void quack() { } public void swim() { swimBehavior.swim(); } public void display() { System.out.println("The duck "+name+ " is at ("+topLeftX+", "+topLeftY +")"); } }