Earlier this week, I decided it was time for the AP students to take a quiz covering the GridWorld case study. In particular, they had been working to implement a subclass of Critter called BlusterCritter, and I wanted to see if they really understood the concepts involved: constructor arguments (and private instance variables), the methods called from the Critter act() method, and using multiple methods (connected by compound dot syntax) and some coordinate geometry arithmetic with the Location and Grid classes.

The first question asked them to implement the following method:

```/*
* Preconditions: getGrid().isValid(upperLeft) == true
*                getGrid().isValid(lowerRight) == true
*
* @return All Actor objects in the rectangular area from
* upperLeft to lowerRight (inclusive).
*/
public ArrayList<Actor> getActorsBetween(Location upperLeft,
Location lowerRight)
{

}```

I was expecting students to write a solution similar to that in the GridWorld solutions manual (which, oddly enough, is the first result on Google when you search for BlusterCritter). Their solution uses nested for loops to scan all the locations in a 5×5 square, and I figured this quiz question wouldn’t be too much of a stretch after seeing that one.

Of course, not everyone was able to make the leap. Most of the students who were able to write a successful solution did it by following that model. But one student recognized a different approach: the Grid class offers a getOccupiedLocations method. He took those occupied Locations and checked each one to see if it fell within the bounding rectangle defined by upperLeft and lowerRight. If it did, he got the occupant and added it to the ArrayList he would return.

I honestly hadn’t anticipated this solution, and that made seeing it all the more gratifying. I feel safe predicting a 4 or 5 on the exam for this student right now. At the same time, I’m still worried about the bottom third of the class that was stumped by this question.