Upcoming SlideShare
Loading in …5
×

# 6. Conditionals I

148 views

Published on

Published in: Education
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

### 6. Conditionals I

1. 1. From last time… • We talked about variables, random(), and casting! • Please write a number from 1–5 on your proposal and turn it in! ! 1 – little/no prior programming experience! ! 5 – extensive prior programming experience
2. 2. Ofﬁce Hours • http://www.cise.uﬂ.edu/class/cap3032sp14/! • Joseph: CSE 410, Mon/Wed, before class! • Yifan: CSE 309, Thurs, 2:00pm–3:00pm
3. 3. Quiz 1! & Interaction Pixels, Processing, CAP
4. 4. Stats • 38 students took the quiz! • 91.3% average score! • Just about 75% of the class was above average! • Read my notes, answer key online
5. 5. Pixel Grid Questions Pg. 6 • The ﬁrst grid row & column is 0! • The upper left hand corner is the origin! • The width & height are total, not “from center”
6. 6. HSB Color Model • Hue, Saturation, Brightness! • The “non-default” color mode! • HSV is close, but Processing won’t understand
7. 7. Conditionals I CAP
8. 8. Relational Operators boolean!! true or false! > < >= <= == != greater than less than greater than OR equal to less than OR equal to equality inequality
9. 9. If if (boolean expression) { // do this if it’s true }
10. 10. If / Else if (boolean expression) { // do this if it’s true } else { // do this if it’s not true }
11. 11. If, Else If, Else if (boolean expression A) { // do this if A is true } else if (boolean expression B) { // do this if B is true } else { // do this if neither A nor B is true }
12. 12. == versus = == ! ! Checks for equality! x == 3 =! ! ! Assigns a value! x = 3
13. 13. Demo! Weighted Probabilities
14. 14. constrain() • Takes three integer or ﬂoat arguments! • Returns an integer or ﬂoat! • constrain(amount, low, high); • Great for color or size:! ! float redColor = constrain(290, 0, 255); ! redColor will be equal to 255
15. 15. Logical Operators && || ! AND OR NOT if if if if if (x == 3 && y == 3) {} (x == 3 || x == 4) {} (x != 3) {} (!keyPressed) {} (keyPressed) {}
16. 16. Demo! Collision Detection
17. 17. For next time… • I will return your proposals on Monday ! • Read Shiffman, p. 70–80 (Conditionals II)! • Will hand out Homework 1 on Friday