Director free response problem from the 2014 AP Computer Science A Exam.
Director is #2 from the from the 2014 AP Computer Science A Free Response problems.
http://media.collegeboard.com/digitalServices/pdf/ap/ap14_frq_computer_science_a.pdf
Director class
public class Director extends Rock { public Director() { super(); // not 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); } }
In the else will points be taken off if I put super()?
Rock
has a constructor that takes aColor
object as a parameter. In theDirector
constructorsuper(Color.RED)
has the same effect assetColor(Color.RED)
.