Continuous February 16, 2009. Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Introduction to Macromedia Director 8.5 – Lingo
Variables Conditionals Boolean Expressions Conditional Statements How a program produces different results based on varying circumstances if, else if,
CS0007: Introduction to Computer Programming
How SAS implements structured programming constructs
Game with US Beginner Tutorial. Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays.
Variables and Operators
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Variables Conditionals Loops The concept of Iteration Two types of loops: While For When do we use them? Iteration in the context of computer graphics.
Data: Programming Design and Modularization IS 101Y/CMSC 101 Computational Thinking and Design Thursday, September 26, 2013 Marie desJardins University.
IAT 334 Java using Processing ______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY.
IAT 800 Foundations of Computational Art and Design Lecture 2.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
ICM Week 2. Structure - statements and blocks of code Any single statement ends with semicolon ; When we want to bunch a few statements together we use.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
PROCESSING Animation. Objectives Be able to create Processing animations Be able to create interactive Processing programs.
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Review Blocks of code {.. A bunch of ‘statements’; } Structured programming Learning Processing: Slides by Don Smith 1.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Loops: Handling Infinite Processes CS 21a: Introduction to Computing I First Semester,
Keyboard and Events. What about the keyboard? Keyboard inputs can be used in many ways---not just for text The boolean variable keyPressed is true if.
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
CPS120: Introduction to Computer Science Decision Making in Programs.
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
Visual Basic Programming
Review Loops – Condition – Index Functions – Definition – Call – Parameters – Return value.
B. RAMAMURTHY Simulating Motion and Implementing Animation.
CIS 3.5 Lecture 2.2 More programming with "Processing"
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Lesson Two: Everything You Need to Know
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 5A Repetition (Concepts)
Mouse Inputs in Processing. Interacting with the Mouse mouseX and mouseY: pg mouseXmouseY –The position of the mouse in the canvas pmouseX and.
Lesson Two: Everything You Need to Know
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
Test 2 Review. General Info. All tests are comprehensive. You are still responsible for the material covered prior to the first exam. You will be tested.
Often being different. Control flow By default Java (and therefore Processing) executes lines of a program one after the other –Doesn’t matter what happened.
LCC 6310 Computation as an Expressive Medium Lecture 2.
Repetition 8/9/2009. Learning to Program -- Suggestions Spend a lot of time fiddling around with code –Programming is something you have to learn by doing.
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
Computer Science I Looping. User input. Classwork/Homework: Incorporate looping & user input into a sketch.
G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 2 More Programming with Processing.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code that may be executed several times. Fixed-count (definite) loops repeat a fixed.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Review Expressions and operators Iteration – while-loop – for-loop.
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
Welcome to Processing Who does not have access to digital camera?
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
Loops. About the Midterm Exam.. Exam on March 12 Monday (tentatively) Review on March 5.
Chapter VII: Arrays.
Introduction To Repetition The for loop
Computation as an Expressive Medium
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Mouse Inputs in Processing
More programming with "Processing"
Introduction to Problem Solving and Control Statements
OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS
Variables & Datatypes CSE 120 Winter 2019
LCC 6310 Computation as an Expressive Medium
Prepared By: Deborah Becker
IAT 800 Foundations of Computational Art and Design
Variables and Operators
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Continuous & Random September 21, 2009.
LCC 6310 Computation as an Expressive Medium
Presentation transcript:

Continuous February 16, 2009

Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?

Test Review What will be printed in the following code? for (int i = 0; i<10; i=1) { print(i + " "); }

Test Review What is the test expression so that the following loop prints the line int count = 0; while ( ___________ ) { print( count + " " ); count = count + 1; }

Test Review Which statement is not true of a variable declaration? Choose one answer. 1. The declaration must be given before the variable is used. 2.The declaration gives a name and a data type for the variable. 3.The declaration gives an initial value to the variable. 4.A variable cannot be used in a program unless it has been declared.

Test Review Examples of primitive data types are (Choose one answer.) 1.boolean, int, float, byte, and character 2.blean, int, float, byte, and char 3.boolean, int, floating, byte, and character 4.boolean, int, float, byte, and char

Test Review What is the meaning of i++ ?

Test Review What is the meaning of i++ ? A variable is What type of looping constructs did we discuss? What data type is appropriate to store the value 5.232?

Test Review What is the meaning of i++ ? A variable is What type of looping constructs did we discuss? What data type is appropriate to store the value 5.232?

Test Review According to the NC DOT, a Level 2 Limited Provisional license requires that a driver must be at least 16 years old, but less than 18, and there may be no more than one passenger under 21 years of age in the vehicle.

Test Review What must the initialization be so that the following fragment prints out the integers ? for ( _______; j < 0; j++ ) println( j );

Test Review What must be added so that the following code prints out the even integers ? for ( int j = 0; j <= 10; _______ ) println( j );

Test Review What must be added so that the following code prints out the even integers ? for ( int j = 0; j <= 10; _______ ) println( j );

Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied only by loops and function calls. –Event Driven Programs run continuously responding to input events such as key strokes or mouse clicks.

How Do Those Classification Pertain to Our Class All the programs we have written or looked at so far are procedural. Today we look at event driven programs. First event driven program void draw() { frameRate(4); //fps = 4 println(frameCount); }

What Happened? About 4 times per second, a number (the frame count) was printed to the console window. Why? –There’s no for loop or while loop? The draw() function is processed continuously by the event handler until another event is triggered or you press the STOP button.

More on Why Specifically the draw() function is called 4 times per second since we set the frameRate to 4. Remove the frameRate() line and see what happens. What’s the default frame rate?

Next Program float y = 0; void draw() { frameRate(10); line(0, y, 100, y); y = y + 0.5; }

How Can We Produce the Following Sketch? Change the line y = y + 0.5; To y = y + 1.5;

Background The background doesn’t refresh automatically so lines just accumulate.

More with Draw() To clear the window at every frame, pt a background() command at the beginning of draw(). Background doesn’t have to use a constant as its argument, change it to use an expression with y.

Can You Add a Conditional to Make the Lines Disappear When They get to the Bottom? float y = 0; float increment = 0.5; void draw() { frameRate(10); background(50+y*2); line(0, y, 100, y); if (y > height) increment *= -1.0; y = y + increment; }

setup() For instructions that just need to be run once, use setup(). float y = 0; float increment = 0.5;

setup() float y = 0; float increment = 0.5; void setup() { size (100, 100); smooth(); fill(0); } void draw() { frameRate(10); background(50+y*2); line(0, y, 100, y); if (y > height) increment *= -1.0; y = y + increment; }

setup() float y = 0; float increment = 0.5; void setup() { size (100, 100); smooth(); fill(0); } void draw() { frameRate(10); background(50+y*2); line(0, y, 100, y); if (y > height) increment *= -1.0; y = y + increment; }

Variable Scope What happens if you declare y –At the top –In draw –In setup

Scope When a variable will change in each iteration of draw, declare it outside of setup() and draw().

Why? When a variable is created within a code block, it can be used only within that block. It will be destroyed with the program leaves the block.

In-class Lab Create a shape that moves from one side of the canvas to the other. When it reaches the opposite edge have it reverse direction and continue back and forth endlessly. For maximum credit make sure your code will work if the window size is set differently.