DXC Technology interview question

factory method