06_05_worksheet
06_05_worksheet
Date:
Activity 1
1. Which chatbot did you use?
4. Think about your conversation with a chatbot. Identify key words to which you think the
chatbot responds.
Activity 2
1. What happens when a key word is included in another word? Consider statements like "I know
all the state capitals" and "I like vegetables smothered in cheese." Explain the problem with the
responses.
2. The lab suggests using the trim method from the String class. How does it work? Show an
example of a String value before and after the trim method is invoked.
3. Paste the code below showing the additional two noncommittal responses added to
getRandomResponse.
4. Complete the table below. List the additional keywords and responses you added to the
getResponse method.
Keyword Response
5. What happens when more than one keyword appears in a string? Consider the string "My
mother has a dog but no cat." Explain how to prioritize responses in the reply method. Did this
impact any changes you made to the getResponse method?
Activity 3
Trace through the following method calls. Write the value of the variables position, before, and
after each time the program control reaches the point in the method indicated by the comment.
5) Your choice. Fill in the parameters and then trace the method call.
findKeyword( "", "", );