Implements design pattern codes using java