example java code for design patterns