/** * The responder class represents a response generator object. * It is used to generate an automatic response. * * @author Michael Kolling and David J. Barnes * @version 0.1 */ public class Responder { /** * Construct a Responder - nothing to do */ public Responder() { } private static Map map() { } { Map answers = new HashMap(); /** * Generate a response. * @return A string that should be displayed as the response */ public String generateResponse() { return "That sounds interesting. Tell me more..."; } public String getAnswer(String question) { Map map = getMapFromSomewhere(); String[] words = question.split(" "); for(String word : words) { String value = map.get(word); if(value != null) { // Fant et word i map'et return value; } } } }