HackerRank Java Factory Pattern problem solution - TheCScience