CS 111 - 11/11/14 Exam 2 - Thursday, 11/13/14 during Lecture 20 multiple choice questions 2 write method questions - modifications on pictures For Extra Credit toward Final Letter Grade - write a potential multiple choice question in the appropriate Blackboard Discussion section Topics: Java - builds on information from first exam, but highlighting - for loops - if statements - Boolean Operators - AND, OR, NOT: && || ! - return values from methods Media - only questions about pictures (no turtles) Picture class/objects - creating a picture -from a filename -from width and height values -from another picture - getWidth() - getHeight() - getPixel (x, y) - write(), show(), explore() Pixel class/objects - getColor(), getRed(), getGreen(), getBlue() - setColor(), setRed(), setGreen(), setBlue() - colorDistance (color1, color2) Color class/object - create a Color Color (redAmount, greenAmount, blueAmount) the range of the parameter values is from 0 to 255 ========================= for write method questions: first line is very important public static Picture name (Picture p ) { Picture result; ... return result; } Note: there are 2 write method questions on Picture and there are two basic forms of picture manipulation - color manipulation - position manipulation ================== int i; for (i = 1 ; i <= 100; i++) { System.out.println (i); } is the same as: int i; i = 1; while ( i <= 100 ) { System.out.println (i); i++; } ================================ // if-then statement if ( ) { statement; } // if-then-else statement if ( ) { statement1; } else { statement2; } // else-if clauses if ( ) { statement1; } else if ( ) { statement2; } else { statement3; } x = 35; y = 0; if ( x < 10 ) { y = 1; } else if ( x < 20 ) { y = 2; } else if ( x < 30 ) { y = 3; } else if ( x < 40 ) { y = 4; } else { y = 5; } -------------------- x = 15; y = 0; if ( x < 10 ) { y = 1; } if ( x < 20 ) { y = 2; } if ( x < 30 ) { y = 3; } if ( x < 40 ) { y = 4; } else { y = 5; } --------------- x = 35; y = 0; if ( x > 0 ) { y = 1; } else if ( x > 10 ) { y = 2; } else if ( x > 20 ) { y = 3; } else if ( x > 30 ) { y = 4; } else { y = 5; } =========================== x y | x && y x || y !x ------------------------------- T T | T T F T F | F T F F T | F T T F F | F F T x = ...; y = ...; z = 0; if ( !(( x >= 4 ) || ( y < 7 )) ) z = z + 1; else if ( !(( x > 4 ) && ( y <= 7 )) ) z = z + 2;