Download presentation
Presentation is loading. Please wait.
1
Week 11 Recap CSE 115 Spring 2007
2
Want to write a programming language? You’ll need three things: You’ll need three things: –Sequencing –Selection Polymorphism Polymorphism If-statements If-statements –Repetition For-each loop (only useful on collections) For-each loop (only useful on collections) For-loop For-loop While-loop While-loop Do-while-loop Do-while-loop
3
For-loop Definite loop / Counting loop – has things built into it to make it easier to count the number of times the loop has executed Definite loop / Counting loop – has things built into it to make it easier to count the number of times the loop has executed Entry-test loop – determining whether to continue looping is determined before the loop body is run. Entry-test loop – determining whether to continue looping is determined before the loop body is run.
4
For-loop Syntax for(initialization; boolean expression; increment){ //code to be repeated }Where: initialization – (typically) creates a variable for the loop counter and sets its initial value boolean expression – (typically) checks the bounds on the loop counter increment – (typically) increments the value of the loop counter after each iteration of the loop
5
While loop Indefinite loop – Will continue to execute until the expression is false – no mechanism built it for prescribing a particular number of iterations. Indefinite loop – Will continue to execute until the expression is false – no mechanism built it for prescribing a particular number of iterations. Entry-test loop Entry-test loop
6
While loop while(boolean expression) { //code to execute repeatedly } Where: Where: –Boolean expression is the expression to be evaluated to indicate the end of the repetition. As long as the expression is true, keep looping.
7
Building a System We are going to spend the rest of the semester building a larger project from scratch. Please see slides about building our game of memory.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.