Section A.4. Conditionals


[Page 547 (continued)]

A.4. Conditionals

An if takes an expression and evaluates it. If it's true, the if's block is executed. If it's false, the else block is executed, if one exists. If you have more than two possibilities, you can add else if for each additional one.

// tint the shadows darker if (redValue < 60) {     redValue = redValue * 0.9;     greenValue = greenValue * 0.9;     blueValue = blueValue * 0.9; } // tint the midtones a light brown // by reducing the blue else if (redValue < 190) {    blueValue = blueValue * 0.8; } // tint the highlights a light yellow // by reducing the blue else {    blueValue = blueValue * 0.9; }




Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net