Identify multiple keywords in the input, and respond with both values (HashMap). Someone might type in "my windows PC crashed". The SupportSystem class should print out responses for both "windows" and "crashed". You should not have the Responder class do any printing. Also, be sure to print each response out only once (i.e. typing in "crash crashed" should not cause the same response to be printed twice).
When posting code it's always best to UseCodeTags to make you code nice and easy to read. I've added them for you this time, see how much better it looks?
Ok, so back to your question. Well, you appear to have forgotten to ask any question at all. All I see is what I assume is your school assignment, and what appears to be someone else's solution to it. What's going on?
Thank you for the code tags. There is no solution to it yet. I did the first part, which was to make a second HashMap with synonyms of keywords from the first. However, I cannot figure out where to start for the second part where we need to be able to get both values (responses) returned if the prompt includes two keywords.
In future it would be very helpful if you explained your problem a bit more fully. "Getting an error" isn't very specific, in fact it doesn't tell us anything at all. However I can see by looking at your code that you aren't saying (in the code) what you want to add to the list.
Chan Duller wrote:
This is what I have added, but I am getting an error when I try to use the add feature of ArrayLists. Any suggestions?
The ArrayList class does not have an add() method that takes no-arguments. It does have an add() method that takes one argument, and it also has an add() method that takes two arguments. Perhaps you meant to call one of those methods instead?
This is the update, but now I am getting the following error: incompatible types: java.util.ArrayList<java.lang.String> cannot be converted to java.lang.String.
I just figured out that it is because it expects a String return type. My only question is, how do I work it when the default response is in String form, and the other is in ArrayList form?