While loops vs For Loops

While loops vs For Loops - While loops vs. For loops -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
While loops vs. For loops - while statements check conditions - for loops have a set quantity - syntax difference o while: increments in loop o for: increment specified, all conditions initialized in statement Volume in forLoop - loop through samples in array - double value-> double amplitude of sound - make method more general o use parameter to decide how much to change volume o don’t use integer but use double Doubles to Ints - can’t assign value of double to a variable of type int - result of an integer times a double is a double o (value*factor) - need to cast from double to integer o use (int)(value*factor) o casting gets rid of fractions Calling a Method from a Method - have decreaseVolume and increaseVolume call changeVolume o use this.changeVolume OR changeVolume invokes method on current object “this” is implicit Force to Extremes - make sounds maximum positive or negative values o via a 16 bit sound o if the value is 0 or positive make it 32,767 o if the value is negative make it -32, 768
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/28/2011 for the course CSCI 053 taught by Professor Sibert during the Fall '10 term at GWU.

Page1 / 2

While loops vs For Loops - While loops vs. For loops -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online