APCS: Magpie Project, Activity 4


4 points

Activity 4 is on pages 10-11 in the Student Guide. Do a File - Save As on Magpie3.java, creating Magpie4.java.

Read pages 10-11 of the Student Guide.

The refinement here is that the chatbot will respond now to phrases as well as to individual words. The chatbot responds to statements of the form "You something me" and the form "I want to something".

There is a link below to the new methods transformIWantToStatement and transformYouMeStatement. Copy and paste these methods into your Magpie4.java file. There are sections of both new methods that are incomplete. Follow the "TO DO" instructions and write the needed code.

Run Magpie4. See how the chatbot responds to these typed-in phrases, and understand why the chatbot responds as it does:
I want to build a robot.
I want to understand French.
Do you like me?
You confuse me.
I want to speak with my father.
You mother me.

Alter the code so that it responds directly to "I want something" statements with "Would you really be happy if you had something?" This can be accomplished by creating a new method transformIWantStatement. To get started, you can copy, paste and modify an existing method.

Alter the code so that it responds directly to "I something you" statements with "Why do you something me?" To do this, you can create a new method transformIYouStatement.

There are examples of the chatbot responding to statements in these forms in the Student Guide.

Resources:
New Methods for Magpie4
MagpieRunner4.java
Javadocs (API) for Magpie4
Student Guide

 

Links:
Magpie Project
AP Computer Science