Okay, this is the only way I'm going to prep.
Tomorrow, I am covering an AP Free Response question at our Super Saturday Tutorial Session.
It's called String Coder.
I've pulled the things I think they need from the Quick Reference, String class, List and some code from the Grid World does a for each.
They get a String Coder class they can use.
They have to do the following:
I always have them write the return stuff first, as that will give some points.
String result = "";
…
return result;
Then I am going to have them figure out how to meet the post condition.
for (StringPart part : parts)
{
int start = part.getStart();
int length = part.getLength();
result += masterString.substring(start, start+length);
}
Next they have to do:
Again, first we have to return an ArrayList of String Part:
ArrayList<StringPart> result = new ArrayList<StringPart>();
and
return result.
In the middle (instead of and).
They have to go through the word, searching the parts of the master string
while (word.length() > 0)
{
StringPart part = findPart(word); (they will find it according to the pre-condition)
result.add(part);
word = word.substring(part.getLength());
}
I'm going to have them give me the answers, I'm going to type the code in and see if it works. If it doesn't, I'm going to have them debug it.
I do have code to try.
If we run out of time, I'll teach them how to program the XBox. The other AP teachers will probably kill me.
Leave a Reply