Codes to test Factory Design patterns in Java