*** Official AP Computer Science A Thread 2013-2014 ***

<p>public class Director extends Rock
{
private boolean isRed;</p>

<p>public Director()
{
setColor(Color.RED);
isRed = true;
}</p>

<p>public void act()
{</p>

<p>if(isRed)
{
setColor(Color.GREEN);
}
else
{
setColor(Color.RED);
}</p>

<p>ArrayList<actor> list = getGrid().getNeighbors(getLocation());
for(Actor a: list)
{
a.setDirection(a.getDirection() + 90);
}</actor></p>

<p>}</p>

<p>isRed = !isRed;
}
}</p>

<p>Here was mine for question 1</p>

<p>public static String scrambleWord(String word)
{
String result = “”;</p>

<p>for(int i = 0; i < word.length(); i++)
{
String current = word.substring(i, i+1);
if(i < word.length() - 1)
{
String next = word.substring(i+1, i+2);
if(current.equals(“A”) && next.equals(“A”))
{
result += current;
}
else if(current.equals(“A”) || next.equals(“A”))
{
result += next + current;
i++;
}
else
{
result += current;
}
}
else
{
result += current;
}
}</p>

<p>return result;</p>

<p>}</p>

<p>AND</p>

<p>for(int i = wordList.size()-1; i>=0; i–)
{
String word = wordList.get(i);
String result = scrambleWord(word);
if(result.equals(word))
wordList.remove(i);
else
wordList.set(i, result);
}</p>

<p>}</p>

<p>For the rock class, all I really did was copy the critter methods from the Appendix and modify them little bit.
ProcessActors, and getActors.</p>

<p>For FRQ #1 Mine was quite very simple!</p>

<p>int in = word.indexOf(“A”);
String newword = “”;
newword = word.substring(0,in) + word.substring(in+1, in+2) + “A” + word.substring(in+2);
return newword; </p>

<p>I’m almost done completing worked out solutions, then I’ll post them here.</p>

<p>is there an equals method for Color? I used an if statement</p>

<p>if (getColor().equals(Color.RED))
{
setColor(Color.GREEN);
} </p>

<p>does that work? I had never used an equals method with Color before but I assumed it existed </p>

<p>yeah there is. .equals is inherited by all Objects. </p>

<p>@QuantumCat‌ </p>

<p>I hate to be that guy, but your code doesn’t work if there are multiple A’s and multiple swaps to be made. indexof only returns the first instance.</p>

<p>I used a for loop, if the current and next characters are A and not A then you add them in reverse order to the answer string and increment the counter by one more.</p>

<p>else you just add the current character to the answer string and move along. </p>

<p>Also for the gridworld problem all you had to do was make a constructor and overwrite the act method</p>

<p>My director was less elegant than all yours but I think it worked. I made a new method</p>

<p>public class Director extends Rock {</p>

<p>private int moves;</p>

<p>public Director()
{
setColor(Color.RED);
moves = 0;
}</p>

<p>public static void act()
{
if (moves%2==0)
{
setColor(Color.GREEN);
turnActors();
}else{
setColor(Color.RED);
}
moves++;
}</p>

<p>public static void turnActors()
{
ArrayList<actor> actors = getOccupiedAdjacentLocations(getLocation());</actor></p>

<p>for (acty: actors)
acty.setDirection(acty.getDirection() + 90);</p>

<p>}</p>

<p>}</p>

<p>@schakrab‌ I did the same thing!</p>

<p>I completely blanked out on part of the Director FRQ, and added a Color instance variable and changed that instead of using setColor/getColor. you guys think this would be penalized? </p>

<p>yeah basically you write the turnActors function into the act mathod…but that should be fine…The moves thing is complex because you can just check what the color is. And I seriously hope you incremented moves on the test. </p>

<p>Haha it must be annoying to be an AP grader for the CS free response because everyone solves the problem in different ways </p>

<p>Also, getOccupiedAdjacent locations gives you a locations array list, not actors. You have to use the grid’s get method for each of the locations to get the actors in that location. </p>

<p>@schakrab‌ </p>

<p>Oh crap I thought it was first occurrence, don’t know why. </p>

<p>I am guessing I just got a 4 then. :S</p>

<p>Worst case senario if I got 50% right on the MC and 25/36 on free response then that means it’s still a 4 according to the 2009 tests atleast. </p>

<p>@fubnub‌
They might penalize you because it’s the collegeboard and they enjoy suffering. But it should be fine i think. </p>

<p>yeah you can make a few mistakes and do well because the curve is more lenient</p>

<p>I’m taking Bio on Monday and that is the hardest AP there is. One silly mistake could doom you because only the top 5-6% of test takers get 5’s. I’ve been getting 5’s on practice tests, I just hope I don’t get nervous and do something stupid. After that I got Euro, and I’m home free because I got two finals and one of them is English :)</p>

<p>Sample worked-out solutions are up here - <a href=“Dropbox - 2014 AP FRQ's.zip - Simplify your life”>Dropbox - 2014 AP FRQ's.zip - Simplify your life;
The archive can be unzipped and imported directly into Eclipse. I wrote a driver class for each of the FRQ’s so you can verify that it works.
Note that this is how <em>I</em> solved the problems, with the exception of finding the price in FRQ#4, I did a complicated set of nested if’s on the test.</p>

<p>for question 4, I made instance variables of name and price, determined and set both in the constructor, and then just returned them for the methods. The price wasn’t hard. I just added together all possible combinations of 2(there were only 3) and set price equal to the highest one. </p>

<p>@yayitsme123 I’m a reader for APCS. Actually, it’s kinda fun to see all the different approaches that students take to a problem. It keeps us interested … considering that we read the same solution over and over for 8 hours a day :)</p>

<p>For the Gridworld question, I accidentally wrote:</p>

<p>Grid<actor> gr=getGrid();
instead of
Grid gr=getGrid();
to reference ArrayList<actors> actor=gr.getNeighbors(getLocation());</actors></actor></p>

<p>Do you guys think they will penalize for it?</p>