Anglo American interview question

ask you to refactor some existing codes