2011 Computer Science Test Thoughts

<p>rahful - I don’t get your code.
You were supposed to return the index of the lowest leveled fuel tank under the threshold if any.</p>

<p>EDIT:
zrath - That’s exactly what I did but I didn’t think of using a while loop.
I just had an int increment if the value was 0, and if it wasn’t 0 then I just used break. But same thing. On GridWorld, you forgot the constructor. You actually could have left it empty since it required no parameters so it would just make a call to the default super().</p>

<p>Do you guys think this is a 5? 29-32 MC correct. 29-32 / 36 FR points?</p>

<p>supercuber - lol, that’s number 3. this is the one where you adjust the values of an array so there are none greater than the threshold and none less than the negative threshold. looking at my code right now, i dont know why i did the && array* > 0… i thought i had a good reason when i added it at the last second when reviewing my code. hmph.</p>

<p>Haha right. I got confused because there was a parameter called Threshold in #3 as well.</p>

<p>@SuperCuber, I think I’m mixing up the question that involved absolute value with this one. I actually probably meant if(whateverItWasCalled[x]<threshold). Ahhhhjdsklfjklasdfjoidsajrioewamklfcmkdsaljklf. I didn’t realize we had to return the lowest value. I misread. THAT’S NOT EVEN HARD! Ugh…going to cry now.</p>

<p>@rahful, Was confused at first. That’s 3. Got it. & That looks right, I had something pretty similar.</p>

<p>I saved the GW one for last and didn’t know that it needed a default constructor… but felt good about everything else.</p>

<p>the sound one was number 3? really?</p>

<p>i could have sworn it was the first.</p>

<p>i’m positive it was the first.</p>

<p>right?</p>

<p>You know what, at this point I have no idea. I think you’re right. I’m confusing myself in so many ways. But I do know which one you’re talking about, and I did do something similar :P</p>

<p>I thought 4.b was pretty simple, but all my classmates thought it was the hardest one. Is it just storing a string in a variable called temp, calling the method that puts message into the array, using a for loop to add every element back into temp, and then calling the other method which encrypts it and returning that, correct?</p>

<p>@supercuber, i dont think you need a constructor. critter class has no constructor, it inherits the one from the actor superclass (makes a blue critter facing north). i don’t think chameleoncritter has a constructor, does it? </p>

<p>either way, i think no constructor is the way to go.</p>

<p>edit: sorry, it does NOT inherit one, constructors are NEVER inherited. but when no constructor is supplied, the compiler makes it use the superclass default constructor.</p>

<p>

</p>

<p>Was this the one where you defined “encryptString()”? I did something like this:</p>

<p>


int numCells = numRows * numCols;
String encrypted = new String();
for (int i = 0; i < message.length(); i += numCells) {
    if (i + numCells > message.length)
        fillBlock(message.substring(i));
    else
        fillBlock(message.substring(i, i + numCells));
    encrypted += encryptBlock();
}
return encrypted; 

</p>

<p>Basically I looped through the string in chunks of size numCells, and stored each chunk in the matrix, encrypted the matrix, and appended the result to a string.</p>

<p>And I think Rahful’s right, you didn’t need a constructor because the problem didn’t require adding any fields to the class (which would need to be initialized in a constructor)–just methods.</p>

<p>^ lol thanks, now that i think about it, i have no idea what i did xD, I didn’t have enough time to really thing through all the logic</p>

<p>Sorry… I actually didn’t know that.
AndrewT that’s what I did as well for 4b.
Argh your implementation was so wonderfully simple though.
Mine was a lot more complicated than it needed to be haha.</p>

<p>@etennis12, I think a 28/40 on MC and a 28/40 on the FRQ is a 5.</p>

<p>@andrewT, why did you say the for loop like that? Dosen’t fillBlock take a string as a parameter so you can just call fillBlock(message) which converts it to the Array and then use a for loop to traverse the array and add every element to String, and then encrypt the String and return that?</p>

<p>^ are you sure the curve is that good?</p>

<p>60-80: 5
45-59: 4
33-44: 3
25-32: 3
0-24: 1</p>

<p>I copied that off a 2009 comp sci thread, so give or take some</p>

<p>No one’s sure any curve is good this year.
They took away penalty for guessing for the first time.
But look here for a decent estimate - [AP</a> Pass - AP Computer Science Calculator](<a href=“http://appass.com/calculators/computerscience]AP”>AP Computer Science Test Score Calculator - AP Pass)
@ DannyNobel - they’ll probably be higher this year.</p>

<p>SuperCuber, can you give me the short pseudocode of what you are supposed to do for 4.b I do not quite understand Andrew’s code. Thanks</p>

<p>



int numCells = numRows * numCols;
//Finds total number of characters to feed to fillBlock
String encrypted = new String();</p>

<p>//Every turn through the for loop will send forward
//a String of numCells length. Note the increment factor.
for (int i = 0; i < message.length(); i += numCells) {
    if (i + numCells > message.length)
//If there aren't enough characters left, sends forward the rest of the String
//to fillBlock to encrypt
        fillBlock(message.substring(i));
//      note: he forget to update to String here
    else
//If there are enough characters left, it sends the next numCells characters into 
//fillBlock to encrypt.
        fillBlock(message.substring(i, i + numCells));
        encrypted += encryptBlock();
}
return encrypted;


</p>