Skip to content
Snippets Groups Projects
Commit f31d34d1 authored by Peter Hertkorn's avatar Peter Hertkorn
Browse files

Initial commit

parent b4be6a60
No related branches found
No related tags found
No related merge requests found
package aliensimulator.predators;
import java.io.IOException;
import java.util.Properties;
public class PredatorFactory {
private Properties properties = new Properties();
public PredatorFactory() {
try {
properties.load(this.getClass().getResourceAsStream("factory.properties"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public Predator createPredator(String type) {
if (type.equals("yautja")) {
return new Yautja();
} else if (type.equals("hishquten")) {
return new HishQuTen();
} else return null;
String handlerName = properties.getProperty(type);
Class<?> classOfProtocolHandler = null;
Predator predator = null;
try {
classOfProtocolHandler = Class.forName(handlerName);
predator = (Predator) classOfProtocolHandler.newInstance();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return predator;
}
}
hishquten=aliensimulator.predators.HishQuTen
yautja=aliensimulator.predators.Yautja
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment