Examination 2

Important: During this exam, you are only allowed to access pages which this page links to, the course webpage (not the Google Groups page), as well as any "slides" that you like from there. (Probably you will only need pages directly linked to from this exam page.) The only programs you should be running are your browser (on these limited pages), and Greenfoot. Access to any other page is forbidden, and will result in a failed exam if noticed.
  1. Simple Computer: Consider the following "Simple Computer" program. What does it do? That is, when the code runs, it ends with a number in the Output field (11 in the case of the data that is given in the snapshot). What function of the data is being computed? (You may wish to run the code, and watch it as it runs.)

    Simple Computer Program

    10 points for properly describing the function of the code. You may want to actually play with the simulator here to answer the question.

    Hints:

    You can earn partial credit for the problem by just commenting on the hints above, if you can not figure the program out as a whole.

  2. Security Papers: (5 points each) For each of the following, give a one or two short sentence answer, using specifics from the referenced paper. (You can even copy the paper's language.)
  3. Greenfoot
    1. Consider the Midterm2PictureWorld.zip zipped greenfoot project. 5 points for doing the following without help:
      1. Download it to somewhere that you can find it.
      2. Unzip it (On a PC, usually right-click it and select the "Expand All" option. On a Mac, just double-click it.)
      3. Start Greenfoot. You should NOT need to download it, but it can be found at www.greenfoot.org if you do need it.
      4. Click Scenario, and open the unzipped folder (not the zip file) that you have created.
      5. Click on "Compile All"
      6. Right click on MyPicture1: Select new MyPicture1() and drag the picture into the white square.
      7. Right click on the picture, and select StripeDiagonal() to see what it does. (You should see diagonals from the top left to the bottom right appear.)
      8. Call me over to your desk when you get this far, you just earned 5 points. Also call me over if you need help getting this far, you cannot work on the next two problems without doing this first.
    2. Complete the stripeOtherDiagonal method (5 points).
      • Right click on Picture1: Select "Open Editor". You will see that the method called "stripeOtherDiagonal()" is missing its code. You need to complete that code, so that when this method runs, it will stripe diagonals from top right to bottom left, instead of top left to bottom right. Write down your method for submission.
      • Hint: Other than the name of the method, the code for this method is literally the same as the code for the stripeDiagonal() method, except for the change of a single character.
    3. mysteryMethod inside of MyPicture2 class (5 points).
      • What would be a good name for the method? That is, what is a descriptive name for what it does?
      • You can look at the code and try to decipher what it does. You can also just create a new MyPicture2 object, and run the method a few times to see what happens, and choose a name based on what it seems to be doing.