Design and coding exercise in java