The StockpileCritter problem from the 2009 AP Computer Science Exam is typical of free response problems that test GridWorld: The AP Computer Science Case Study. The problem requires you to extend the Critter class, determine which methods to override, and implement the entire subclass.

StockpileCritter is #2 from the 2009 AP Computer Science Free Response.

StockpileCritter class

public class StockpileCritter extends Critter
    private int stockpile = 0;

    public void processActors(ArrayList<Actor> actors)
        for(Actor a : actors)


    public Location selectMoveLocation(ArrayList<Location> locs)
        if(stockpile < 0)
            return null;
            return super.selectMoveLocation(locs);

2009 AP CS Exam Free Response Solutions

Help & comments

Get help from AP CS Tutor Brandon Horn

Comment on StockpileCritter