Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Identify multiple keywords in the input, and respond with both values (HashMap)

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).

 
Sheriff
Posts: 4766
310
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Chan Duller
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chan Duller
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is what I have added, but I am getting an error when I try to use the add feature of ArrayLists. Any suggestions?
 
Marshal
Posts: 25215
64
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author
Posts: 23868
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?

Henry
 
Chan Duller
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
Chan Duller
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 6858
182
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't you just want to return response instead of responses?
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!