Week 04
Conditional Statements, Repeat Loops
Back Then Schematic >>> Now Faster to Prototype! >>> Real World!
Was there IoT in 2009??
Conditional Statements
How does computer language make different decision? So far we learned setup() : something happens at the start, draw(): something same event happens over and over. Also we learned event function like : mousepressed.
Something changes over time.
Today we want to learn something that happens different from previous event. For example, the color of the ellipse changes after one draw, the position of the rectangle change over based on the position of the user's mouse.
Conditional Logic/ Control Structure
if something is true : Do this code
if something is not true : Don't do this code
Boolean Expression (George Boole) : True / False
Relational Operator
5 > 8 : False
7 < 210 : True
if statement
Computer Language != Mathematical Expression
In-class
Let's make it bouncing! Console.log()
Working Great!
if-else statement
if - else if - else if statement
if - if - if statement
AND
100 < mouseX AND mouseX < 200
OR
x < 0 OR x > height
Repeat Loops
While ...하는 동안
Ellipses one by one....
While loop
While loop has 3 components:
Initial Variable
Boolean Condition Test
Incremental Function
For Loop
Incremental Methods
For - For Loops
Assignment
Make a sketch using both Conditional Statements and Repeat Loops.
Last updated