CS 101 - 10/11/11 Project 2: Start with 2 pictures Picture 1 => black&red Picture 2 => black&cyan (green/blue) Final picture => combine the black&red picture with the black&cyan picture Picture 1 => red color value for a pixel Picture 2 => green/blue color value for a pixel key: each pixel has 3 color values (red, green, blue) in the final picture: red value comes from picture 1 green/blue values come from picture 2 ----------------------------------- Assignment statements Looping statements (while, for, do-while) Methods If statements Selection Statement - does a section of code get executed or not If then form of the if statement if ( ) { ; } Example: Absolute value |-3x| int x; x = SimpleInput.getIntNumber("Enter a value"); if ( x < 0 ) { x = -x; } SimpleOutput.showInformation ("The absolute value is: " + x); ----------------------- If then else form / If else form of the if statement if ( ) { ; } else { ; } if the is true, is executed; otherwise, is executed; Example: finding the larger of two numbers int x; int y; int max; if ( x < y ) { max = y; } else { max = x; } SimpleOutput.showInformation ("The larger value is: " + max); ---------------------------------- Posterization - a technique ussed to reduce the number of colors to a set amount. 4 color posterization white, green, blue, black ----------------------------------- Boolean Operators - combine multiple boolean expressions and: && or: || not: ! And: if both operands are true, the result is true; otherwise the result is false Or: if either operand is true, the result is true; otherwise the result is false Not: if the operand is false, the result is true; otherwise the result if false Truth Table: op1 op2 | op1 && op2 | op1 || op2 ===========|===============|============ T T | T | T T F | F | T F T | F | T F F | F | F op | !op =====|======= T | F F | T