/**
* 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<String,String> answers = new HashMap<String,String>();
/**
* 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<String, String> 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;
}
}
}
}