Shape Factory(LintCode 497):

Problem