Implementation of DesignPattern using java