exercising java design pattern