Early on in Head First Design Patterns the authors say, "'Program to an interface' really means 'Program to a supertype'".
By replacing public interface FlyBehavior
with public abstract class FlyBehavior
from the book's strategy pattern example at http://www.headfirstlabs.com/books/hfdp/HeadFirstDesignPatterns_code102507.zip we can try this out:
$ javac *.java
$ java Run
I'm a real Mallard duck
I'm flying!!
I'm a rubber duckie
I can't fly
$ ./plantuml.sh
Creating abstract-classes.uml...
PlantUMLDoclet.createPlantUml() - start
open outputfile: abstract-classes.uml
write interfaces/ abstract classes...
write content...
write Element MallardDuck...
write Element Duck...
write Element FlyWithWings...
write Element FlyNoWay...
write Element RubberDuck...
write Element FlyBehavior...
PlantUMLDoclet.createPlantUml() - end
Done.
Converting abstract-classes.uml to png...
Done.
If you have Maven installed:
mvn clean compile package exec:java --quiet
java -jar target/supertype*jar
See also:
Thanks for sharing. Great job (plantuml diagram generation).