Basic design pattern implement in java