CSE 8A : Fall 2012
  • Home
  • Calendar
  • Assignments/Labs
  • Course Material
  • Tutor Hours
  • Lab Schedule

Reading Quiz Questions

These are the questions that will appear on the reading quizzes in week 4.  Remember these quizzes take place at the start of class, and you get points for correctness, not just participation.  These will be the exact questions we ask you.  They will be multiple choice clicker questions, but we do not provide the answer choice here.  If you can answer them without the answer choices, you'll have no problems answering them when you see the choices.  These are not designed to be overly tricky.

Tuesday, Oct 23

1. If this is the header to a function defined in Picture.java:
    
     public Picture scaleUp(int numTimes)
     {
          ....
     }

What should the method call look like if I call it on a Picture object named pictObj and I wanted to use the Picture object that it returns?



2. To scale a picture smaller by 2 (to make a copy of the picture that is half the size of the source) what should go in the blanks

     public void copySmaller()
     {
          Picture pictObj = new Picture(FileChooser.pickAFile());
          Pixel sourcePixel = null;
          Pixel targetPixel = null;

          //loop through the columns
          for(int sourceX=0, targetX=0; sourceX < pictObj.getWidth();____1_____, targetX++)
          {
               //loop through the rows
               for(int sourceY=0; targetY=0; soruceY < pictObj.getHeight();____2____, targetY++)
               {
                    sourcePixel = pictObj.getPixel(sourceX, sourceY);
                    targetPixel = this.getPixel(targetX,targetY);
                    targetPixel.setColor(sourcePixel.getColor());
               }
          }     }



3. How do I blend two picture objects with 50% of one picture and 50% of another picture?

4. Imagine that you have a method copyPictureTo, whose header is below, defined in Picture.java.  This method copies the source Picture (sourcePicture) and places its top left corner at (xStart, yStart) of the Picture that called the copyPictureTo method.

public void copyPictureTo(Picture sourcePicture, int xStart, int yStart)

Assume you have already created two Picture objects: sourcePic and pictObj, and you make the following call:

pictObj.copyPictureTo(sourcePict, pictObj.getWidth()/2, 0);

Which picture below best represents where the sourcePic will be located in picObj after the call?  Assume that sourcePic is much smaller than pictObj.

Thursday, Oct 25

No reading questions.  IN TERM EXAM 2 on October 25th
Powered by Create your own unique website with customizable templates.