Director
is #2 from the from the 2014 AP Computer Science A Free Response problems.
https://secure-media.collegeboard.org/digitalServices/pdf/ap/ap14_frq_computer_science_a.pdf
Director
class
public class Director extends Rock
{
public Director()
{
super(); // not strictly required since Rock has a default constructor
setColor(Color.RED);
}
public void act()
{
if(Color.GREEN.equals(getColor()))
{
for(Actor a : getGrid().getNeighbors(getLocation()))
a.setDirection(a.getDirection() + Location.RIGHT);
setColor(Color.RED);
}
else
setColor(Color.GREEN);
}
}
See Class writing order for a technique to respond to AP CS FR that request an entire class.
2014 AP CS Exam Free Response Solutions
- scrambleWord and scrambleOrRemove free response solution
- SeatingChart free response solution
- Trio free response solution
Help & comments
Get help from AP CS Tutor Brandon Horn