• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).

 
Marshal
Posts: 5731
347
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't you just want to return response instead of responses?
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic