Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Pre-quiz 1-Spring 2007

Pre-Quiz1(Spring 2007)

Q1. Who's your grading TA?(Please circle your answer)

Ricardo    Brian    Mark    Rory    Derek    Sarah    Kristin    REMOVEDel


Q2. True or False
Answer the following questions by circling either True or False.

1. Java is not case-sensitive
(ie...Pixel and pixel are considered the same thing) ________True________False

2. int means "integer" and cannot store decimal values ________True________False


Q2. Below is the negate method in the class Picture:

/**
   *Method to negate the picture*/
  public void negate()
  {
    Pixel pixel = null;
    
    // get the array of pixels 
    Pixel[] pixels = this.getPixels();
    
    // loop through all the pixels
    for (int i = 0; i < pixels.length; i++)
    {
      // get the current pixel
      pixel = pixels[i];
      
      // set the pixel color values to the new values
      pixel.setRed(255 - pixel.getRed());
      pixel.setGreen(255 - pixel.getGreen());
      pixel.setBlue(255 - pixel.getBlue());
    }
  }


Recall that creating a grayscale version of a picture is done by setting the red, green, and blue all to the same value.
A good value to use is the average of the red, green, and blue pixel values.

*Rewrite this method as a grayscale() method.* And be sure to use a while loop in your solution.


Questions? Comments? Post them on Pre-Quiz 1-Spring 2007 Questions

Link to this Page