8. Loops I

135 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
135
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

8. Loops I

  1. 1. From last time… • We played with Pong! • Please turn in Homework 1
  2. 2. Proposal! Feedback CAP
  3. 3. Proposals • Check your email, take action if needed! • Scope, definition, and clarifications! • Thoughts and examples! • Think of this as a loose ‘contract’! • Next steps: iteration plan and group formation
  4. 4. What is Agile? CAP
  5. 5. (Semi-) Agile • Follow “user stories” rather than specifications! • Frequent check-ins (scrums) with your team! • 2 week development cycles (sprints)! • We will be meeting in groups on a regular basis, will have quick scrums, then show off our work, ~ 3 week development sprints
  6. 6. Looooooooops CAP
  7. 7. while() while (conditional_statement) { // execute this code }
  8. 8. Demo! While Loops
  9. 9. Infinite Loops (!!!) while (conditional_statement) { // execute this code } • If your conditional statement is never going to be false, the loop will never stop executing! • This is bad.
  10. 10. for() for (int i = 0; i < 10; i++) { print(i); } ! 0123456789
  11. 11. 1. Initialization • Declare and initialize a variable! • Most often: • This could be used as a counter inside the loop, or could be ignored within the loop for( int i = 0;
  12. 12. 2. Boolean Test • Create a conditional statement that must evaluate to true or false! • Most often: • We’ve seen these conditional statements before i < numberOfIterations;
  13. 13. 3. Iteration Expression • What happens at the end of each loop?! • Most often: • Increment or decrement are common here i++) {}
  14. 14. Memorize the For Loop for (int i = 0; i < 10; i++) { print(i); } ! These are extremely helpful in many ways and you will use them often
  15. 15. Demo! Nested For-Loops
  16. 16. Particle Fever http://www.youtube.com/watch?v=Rikc7foqvRI
  17. 17. Particle Fever http://www.youtube.com/watch?v=Rikc7foqvRI
  18. 18. For next time… • Read and respond to your proposal feedback (if you haven’t already)! • Memorize the for loop! • Read Shiffman, p. 90–98 (Loops II)! • Also… start thinking about Iteration 1

×