Loops
New Terminology
- pre-condition loop
- A loop where the decision to continue occurs before the
body of the loop is executed.
- post-condition loop
- A loop where the decision to continue occurs after the body
of the loop is executed.
- counted loop
- A specific type of precondition loop which includes the initialization, condition, and update in the loop header structure
- loop control variable(s)
- One or more variables whose value(s) determine how long the
loop will continue.
- sentinel (sentinel value)
- A value which is used to stop (or continue) loop execution.
- flag
- A boolean value that flags the end condition of a loop execution
- accumulator
- A variable that serves to accumulate a series of values.
Usually used in summation, but may be used for any repeated
operation.
- initialization
- For loops, this is the place where we set-up one or more
variables that will be used to control loop execution.
- decision
- For loops, this determines how long the loop will continue
to execute.
- update
- For loops, this step changes the loop control variables to
approach the ending condition.
- body
- For loops, this is the code that may repeatedly execute.
Java Specific Terms
- while loop
- A precondition loop in java
- do while loop
- A post condition loop in java
- for loop
- A precondition, counting loop in java
Class notes
- Review lab (EightBall.java)
- EightBallDriverV1.java Setup for the future iterations
- EightBallDriverV2.java One way to set up validation (while loop)
- EightBallDriverV3.java Another way to set up validation (do loop)
- EightBallDriverV4.java Adding in the continuation piece for a full application