public void main ( ) {
Boolean testResult = true ; Number userInputValue = 1 ; |
|
//
Copyright 2007, R.G.Baldwin |
// Illustrates use of a "while" loop. |
// Program loops for as long as user keeps entering |
// even integers. Terminates on odd integer. |
// Perform a priming read. |
doInOrder { . . . . . } |
|
// Get user input. |
userInputValue .set( value , ( NumberDialog( question = Enter an integer. ) ) ); |
// Compute remainder after dividing by 2 and return true |
// if remainder is equal to 0 |
testResult .set( value , ( ( Math.IEEERemainder( userInputValue , 2 ) ) == 0 ) ); |
} |
// Execute a "while" loop. |
while ( testResult ) { . . . . } |
|
// Execute this code when testResult is true. |
penguin .say( Even, keep on looping. ); duration = 2 seconds |
// Update value of testResult. |
doInOrder { . . } |
|
userInputValue .set( value , ( NumberDialog( question = Enter an integer. ) ) ); |
testResult .set( value , ( ( Math.IEEERemainder( userInputValue , 2 ) ) == 0 ) ); |
} |
} |
// Execute this code when testResult is false. |
doTogether { . . . . } |
|
// Penguin speaks, turns, and walks away. |
penguin .say( Odd, I'm outa here. ); duration = 20 seconds |
penguin .turn( RIGHT , .375 revolutions ); |
penguin.walking ( x = 100 ); |
} |
} |