Design Pattern demo code in java