0% found this document useful (0 votes)
9 views4 pages

06_05_worksheet

Uploaded by

joasdegraaf2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

06_05_worksheet

Uploaded by

joasdegraaf2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name:

Date:

Magpie Chatbot Lab


Directions: Make note of your responses to the following questions as you work through activities 1, 2,
and 3 of the AP Computer Science Lab: Magpie.

Activity 1
1. Which chatbot did you use?

2. Paste your conversation with the chatbot below.

3. What was the most interesting or peculiar response? Why?

4. Think about your conversation with a chatbot. Identify key words to which you think the
chatbot responds.

5. Suggest several key words and the possible corresponding responses.

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.

1) findKeyword( "She’s my sister", "sister", 0);

Iteration position before after

2) findKeyword( "Brother Tom is helpful", "brother", 0);

Iteration position before after

3) findKeyword( "I can’t catch wild cats.", "cat", 0);


Iteration position before after

4) findKeyword( "I know nothing about snow plows.", "no", 0);

Iteration position before after

5) Your choice. Fill in the parameters and then trace the method call.
findKeyword( "", "", );

Iteration position before after


Iteration position before after

You might also like