Pre-Quiz1 - Fall 2006
Q1. Who's your grading TA? (Please circle your answer)
Dawn Joel Mark Brian REMOVEDng-Yen Richard
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. In Java, the "int" data type is used to hold an integer value. ___________True________False___________
Q3. 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.
- Rewrite this method as a grayscale() method using the average of the red, green, and blue pixel values for each pixel.
- You MUST use a while loop in your solution.
Questions? Answers? Comments?
Link to this Page
- Pre-Quizzes-Fall 2006 last edited on 27 December 2006 at 5:08 pm by 24-241-99-170.static.stls.mo.charter.com