APCS: Magpie Project, Activity 3

3 points

Activity 3 is on pages 6-9 in the Student Guide. Do a File - Save As on Magpie2.java, creating Magpie3.java. You can download MagpieRunner3.java if you choose to. (StringExplorer.java is listed below because it is mentioned in Activity 3, but you don't have to download it.)

Read pages 6-9 of the Student Guide.

The refinement in this activity is addition of the method findKeyword. There is a link to the method below. Copy and paste the findKeyword method into your Magpie3.java file.

Study the method to understand how it works - how it finds 'goal' in 'statement'. In the Java API, in the String class, have a look at the version of the indexOf method with the header line: public int indexOf(int ch, int fromIndex). It is used in findKeyword().

The method findKeyword is not complete. Find the one section that is not complete (find the TO DO) and write the needed code.

Make notes on how Magpie3 responds if you enter each of these lines, and understand why Magpie3 sometimes offers a specific response and other times responds randomly:
She's my sister.
Brother Tom is helpful.
Their team name is the Wildcats.
I know nothing about snow plows.
The password is 12dog34.
The password is 12doggy.

You do not have to do the other exercises that are listed in the Student Guide for Activity 3.

Java API (for info on the String class)
Javadocs (API) for Magpie3
Student Guide


Magpie Project
AP Computer Science