import java.util.ArrayList;
import java.util.HashMap;
public class Controller {
HashMap
public Controller(){
map.put("Is there homework in this class?", "application.AnswerOne");
map.put("Where can I find more information about that?", "application.AnswerTwo");
map.put("How can I avoid those ‘Oh, crap!’ moments?", "application.AnswerThree");
}
public void handleRequest(String question, ArrayList parameters){
String className = (String) map.get(question);
try {
Class aClass = Class.forName(className);
Command aCmdObject = (Command) aClass.newInstance();
aCmdObject.invoke(parameters);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
No comments:
Post a Comment