Factory Test Program (Java version)