package Strategy; // birds can fly (with strategy help) public abstract class Bird implements FlyingThing{ // class that contains my flying method private FlyStrategy myfly; public Bird(){ // subclasses fill in your own or you get nothing myfly = new DontFly(); } // I con't fly, I have a little strategy to do that for me public void fly(int distance, String dir){ myfly.fly(distance, dir); } public FlyStrategy getMyfly() { return myfly; } public void setMyfly(FlyStrategy myfly) { this.myfly = myfly; } // when I break my wing, I get a bad fly method public void breakWing() { System.out.println("Ouch, I broke my tiny bird bones"); setMyfly(new DontFly()); } }