SlideShare a Scribd company logo
1 of 83
Download to read offline
REVIEW LAST WEEK
To create a new list (to declare it):




  int[] x = new int[4];
To create a new list (to declare it):
what kind of things are in the list?
i.e. how much space needs to be
      reserved for each item

             int[] x = new int[4];
To create a new list (to declare it):
 what kind of things are in the list?
 i.e. how much space needs to be
       reserved for each item

              int[] x = new int[4];


[ ] means the data
  type is an array
To create a new list (to declare it):
 what kind of things are in the list?
 i.e. how much space needs to be
       reserved for each item

              int[] x = new int[4];


[ ] means the data
  type is an array
               what is the name of the list?
To create a new list (to declare it):
 what kind of things are in the list?
 i.e. how much space needs to be
       reserved for each item         how long will the list be?

              int[] x = new int[4];


[ ] means the data
  type is an array
               what is the name of the list?
if ( )
{

}
else {

}
put in a comparison
     statement (like < or >)

if ( )
{

}
else {

}
put in a comparison
     statement (like < or >)

if ( )
          what to do if our comparison
{               statement is true


}
else {

}
put in a comparison
     statement (like < or >)

if ( )
           what to do if our comparison
{                statement is true


}
else {

}
         what to do if our comparison
               statement is false
put in a comparison
                             statement (like < or >)

                        if ( )
                                   what to do if our comparison
                        {                statement is true


                        }
   we don’t have to
 always have an else
                        else {
statement, sometimes
 you only care if the   }
   statement is true
                                 what to do if our comparison
                                       statement is false
What if we want to use multiple if statements?



       int counter;
       // some other code...
       if (counter < 10) {
         if (counter > 0 ) {
           counter++;
         }
       }
What if we want to use multiple if statements?

                    If counter is less than 10
                       and greater than 0, then
       int counter;     increase counter by 1.
       // some other code...
       if (counter < 10) {
         if (counter > 0 ) {
           counter++;
         }
       }
What if we want to use multiple if statements?

                    If counter is less than 10
                       and greater than 0, then
       int counter;     increase counter by 1.
       // some other code...
       if (counter < 10) {
         if (counter > 0 ) {
           counter++;
         }
       }              counter is only increased if
                          both if statements are true.
What if we want to use multiple if statements?

                             If counter is less than 10
                                and greater than 0, then
                int counter;     increase counter by 1.
                // some other code...
                if (counter < 10) {
                  if (counter > 0 ) {
                    counter++;
                  }
                }              counter is only increased if
These are called nested if        both if statements are true.
statements, because one is
 inside the { } of the other.
What if we want to use multiple if statements?


        int counter;
        // some other code...
        if (counter > 10) {
          counter = 0;
        }
        if (counter < 0 ) {
          counter = 0;
          }
        }
What if we want to use multiple if statements?
                 If counter is greater than 10 or less
                     than 0, then reset counter to 0.
        int counter;
        // some other code...
        if (counter > 10) {
          counter = 0;
        }
        if (counter < 0 ) {
          counter = 0;
          }
        }
What if we want to use multiple if statements?
                  If counter is greater than 10 or less
                      than 0, then reset counter to 0.
        int counter;
        // some other code...
        if (counter > 10) {
          counter = 0;
        }
        if (counter < 0 ) {
          counter = 0;
          }
        } counter is reset
                if either if
           statements are true.
BOOLEAN OPERATOR OR

True    OR   False   is

False   OR   True    is

True    OR   True    is

False   OR   False   is
BOOLEAN OPERATOR OR

True    OR   False   is   True

False   OR   True    is

True    OR   True    is

False   OR   False   is
BOOLEAN OPERATOR OR

True    OR   False   is   True

False   OR   True    is   True

True    OR   True    is

False   OR   False   is
BOOLEAN OPERATOR OR

True    OR   False   is   True

False   OR   True    is   True

True    OR   True    is   True

False   OR   False   is
BOOLEAN OPERATOR OR

True    OR   False   is   True

False   OR   True    is   True

True    OR   True    is   True

False   OR   False   is   False
BOOLEAN OPERATOR OR

True    OR   False   is   True

False   OR   True    is   True
                              When using OR in
                                code, type ||
True    OR   True    is   True

False   OR   False   is   False
int counter;
// some other code...

if (counter > 10) {
  counter = 0;
}
if (counter < 0 ) {
  counter = 0;
  }
}
int counter;
// some other code...

if (counter > 10) {
  counter = 0;
}
if (counter < 0 ) {
  counter = 0;
  }
                 int counter;
}
                 // some other code...

                if ((counter < 0) ||
                counter > 10)) {
                  counter = 0;
                }
int counter;
// some other code...

if (counter > 10) {
  counter = 0;
}
if (counter < 0 ) {            OR
  counter = 0;
  }
                 int counter;
}
                 // some other code...

                if ((counter < 0) ||
                counter > 10)) {
                  counter = 0;
                }
BOOLEAN OPERATOR AND

 True AND False    is

 False AND True    is

 True AND True     is

 False AND False   is
BOOLEAN OPERATOR AND

 True AND False    is   False

 False AND True    is

 True AND True     is

 False AND False   is
BOOLEAN OPERATOR AND

 True AND False    is   False

 False AND True    is   False

 True AND True     is

 False AND False   is
BOOLEAN OPERATOR AND

 True AND False    is   False

 False AND True    is   False

 True AND True     is   True

 False AND False   is
BOOLEAN OPERATOR AND

 True AND False    is   False

 False AND True    is   False

 True AND True     is   True

 False AND False   is   False
BOOLEAN OPERATOR AND

 True AND False    is   False

 False AND True    is   False
                           When using AND in
                            code, type &&
 True AND True     is   True

 False AND False   is   False
int counter;
// some other code...

if (counter < 10) {
  if (counter > 0 ) {
    counter++;
  }
}
int counter;
// some other code...

if (counter < 10) {
  if (counter > 0 ) {
    counter++;
  }
}
                 int counter;
                 // some other code...

                if ((counter > 0) &&
                (counter < 10)) {
                  counter++;
                }
int counter;
// some other code...

if (counter < 10) {
  if (counter > 0 ) {
    counter++;                 AND
  }
}
                 int counter;
                 // some other code...

                if ((counter > 0) &&
                (counter < 10)) {
                  counter++;
                }
BOOLEAN OPERATOR NOT

     NOT True    is

     NOT False   is
BOOLEAN OPERATOR NOT

     NOT True    is   False

     NOT False   is
BOOLEAN OPERATOR NOT

     NOT True    is   False

     NOT False   is   True
BOOLEAN OPERATOR NOT

     NOT True    is   False

     NOT False   is   True


       When using NOT in
          code, type !
int stopLoop = 0;
// some other code...

if(!stopLoop) {
  // some more code...
}
NOT


 int stopLoop = 0;
 // some other code...

 if(!stopLoop) {
   // some more code...
 }
LOOPS
 There are two ways to
 repeat something:
1. Do this N number of
   times.
2. Keep doing this until
   something else happens.
LOOPS
 There are two ways to
 repeat something:
              Repeat this event in
1. Do this   N the calendar of
               number this
   times.        many times.


2. Keep doing this until
   something else happens.
LOOPS
 There are two ways to
 repeat something:
              Repeat this event in
1. Do this   N the calendar of
               number this
   times.        many times.


2. Keep doing this event in the
         Repeat this until
          calendar until a certain
   something else occurs.
               date happens.
DO THIS N TIMES


int i;
for(i=0; i<4; i++) {

}
DO THIS N TIMES
start with a number, in
      this case 0
                 int i;
                 for(i=0; i<4; i++) {

                 }
DO THIS N TIMES
start with a number, in   if this statement is
      this case 0                  true

                 int i;
                 for(i=0; i<4; i++) {

                 }
DO THIS N TIMES
start with a number, in   if this statement is
      this case 0                  true

                 int i;
                 for(i=0; i<4; i++) {

                 }
  then do whatever is
     written here
DO THIS N TIMES
start with a number, in   if this statement is
      this case 0                  true

                 int i;
                 for(i=0; i<4; i++) {

                 }
                                     when you’ve done what’s
  then do whatever is                 in the { } once, do this, in
     written here                    this case add make i equal
                                     to its current value plus 1
DO THIS N TIMES
start with a number, in   if this statement is
                                   true           go back to see if the
      this case 0                                middle statement is still
                 int i;                                   true
                 for(i=0; i<4; i++) {

                 }
                                     when you’ve done what’s
  then do whatever is                 in the { } once, do this, in
     written here                    this case add make i equal
                                     to its current value plus 1
KEEP DOING THIS UNTIL
SOMETHING ELSE HAPPENS


      while ( ) {

      }
KEEP DOING THIS UNTIL
SOMETHING ELSE HAPPENS
          if the statement here is true


      while ( ) {

      }
KEEP DOING THIS UNTIL
SOMETHING ELSE HAPPENS
          if the statement here is true


      while ( ) {

      }
              then do what is between { } once
KEEP DOING THIS UNTIL
      SOMETHING ELSE HAPPENS
                          if the statement here is true


                     while ( ) {
then repeat by checking
  the statement again
                     }
                              then do what is between { } once
EXERCISE
Write out each iteration of these loops and what the variables
equal at the end of each loop.


int i;
                                   int k = 100;
int j = 15;
                      while ( k > 0 ) {
for (i=0; i<5; i++) {
                        k = k -10;
  j = j * 2 - i;
                      }
}
EXERCISE

Go through code at http://processing.org/learning/basics/
embeddediteration.html

• identify   all of the variables, why were those data types chosen?

• identify   all of the comparisons made

• identify   all control structures

• draw   a diagram explaining what is happening in the code
float box_size = 11;
float box_space = 12;
int margin = 7;

size(200, 200);
background(0);
noStroke();

// Draw gray boxes

for (int i = margin; i < height-margin; i += box_space){
  if(box_size > 0){
    for(int j = margin; j < width-margin; j+= box_space){
      fill(255-box_size*10);
      rect(j, i, box_size, box_size);
    }
    box_size = box_size - 0.6;
  }
}
float box_size = 11;
float box_space = 12;
int margin = 7;

size(200, 200);
background(0);
noStroke();

// Draw gray boxes

for (int i = margin; i < height-margin; i += box_space){
  if(box_size > 0){
    for(int j = margin; j < width-margin; j+= box_space){
      fill(255-box_size*10);
      rect(j, i, box_size, box_size);
    }
    box_size = box_size - 0.6;
  }
}
float box_size = 11;
float box_space = 12;
int margin = 7;

size(200, 200);
background(0);
noStroke();

// Draw gray boxes

for (int i = margin; i < height-margin; i += box_space){
  if(box_size > 0){
    for(int j = margin; j < width-margin; j+= box_space){
      fill(255-box_size*10);
      rect(j, i, box_size, box_size);
    }
    box_size = box_size - 0.6;
  }
}
float box_size = 11;
float box_space = 12;
int margin = 7;

size(200, 200);
background(0);
noStroke();

// Draw gray boxes

for (int i = margin; i < height-margin; i += box_space){
  if(box_size > 0){
    for(int j = margin; j < width-margin; j+= box_space){
      fill(255-box_size*10);
      rect(j, i, box_size, box_size);
    }
    box_size = box_size - 0.6;
  }
}
float box_size = 11;
float box_space = 12;
int margin = 7;

size(200, 200);
background(0);
noStroke();

// Draw gray boxes

for (int i = margin; i < height-margin; i += box_space){
  if(box_size > 0){
    for(int j = margin; j < width-margin; j+= box_space){
      fill(255-box_size*10);
      rect(j, i, box_size, box_size);
    }
    box_size = box_size - 0.6;
  }
}
FUNCTIONS
input




function




output
A function is something that can take input,
do something, and then output something.
                               input




                             function




                              output
A function is something that can take input,
do something, and then output something.
                               input
                                                 The input and
                                               output are optional,
                                               some functions do
                                                 not have both.
                             function




                              output
A function is something that can take input,
do something, and then output something.
                               input
                                                 The input and
                                               output are optional,
                                               some functions do
                                                 not have both.
                             function




  Functions exist so that
    you don’t have to         output
   write a lot of code.
When you call the function size( )

size(300, 400);
When you call the function size( )

                              it creates a window with the
size(300, 400);
                              parameters you entered
When you call the function size( )

                              it creates a window with the
size(300, 400);
                              parameters you entered

and then the program continues with the next line of code.
When you call the function size( )

                              it creates a window with the
size(300, 400);
                              parameters you entered

and then the program continues with the next line of code.

It has a return type of void, so there’s nothing given back
directly to your program, but it does some work for you. It
created the window.
When you call the function size( )

                               it creates a window with the
size(300, 400);
                               parameters you entered

and then the program continues with the next line of code.

It has a return type of void, so there’s nothing given back
directly to your program, but it does some work for you. It
created the window.

In Processing, (as far as I know) all functions have a void
return type.
void   means that nothing is returned.
void   means that nothing is returned.



void setup( ) {

}
void   means that nothing is returned.



void setup( ) {
                   is typed when you want to have
                   something happen between { }.
}
void    means that nothing is returned.



void setup( ) {
                       is typed when you want to have
                       something happen between { }.
}



    The void in front of setup means nothing is
    returned after setup( ) is finished.
In Arduino:




int val = 0;
int inPin = 7;
val = digitalRead(inPin);
In Arduino:




int val = 0;
int inPin = 7;
val = digitalRead(inPin);

               function name
In Arduino:


                             input
                         parameters and
int val = 0;                  type
int inPin = 7;
val = digitalRead(inPin);

               function name
In Arduino:


                                                input
                                            parameters and
              int val = 0;                       type
              int inPin = 7;
              val = digitalRead(inPin);

                                  function name
an int is returned, so it needs
  to be stored somewhere
FINAL EXERCISE
Create a Processing program that
       generatively draws depending on the
                  mouse position.

                           void setup() {
                             // create the window
                             size(400, 400);
Within your program use:   }

   • Variables             void draw() {
                             // set the colour
   • For  or while loop      fill(10, 10, 255);
   • If or if/else             // draw the circle
                               ellipse(mouseX, mouseY,
                               100, 100);
Start with this code.      }

More Related Content

What's hot

C programming perso notes
C programming perso notesC programming perso notes
C programming perso notesMelanie Tsopze
 
A 64-bit horse that can count
A 64-bit horse that can countA 64-bit horse that can count
A 64-bit horse that can countAndrey Karpov
 
The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...PVS-Studio
 
Loop structures chpt_6
Loop structures chpt_6Loop structures chpt_6
Loop structures chpt_6cmontanez
 
Lecture no 1
Lecture no 1Lecture no 1
Lecture no 1hasi071
 
5. using variables, data, expressions and constants
5. using variables, data, expressions and constants5. using variables, data, expressions and constants
5. using variables, data, expressions and constantsCtOlaf
 
02. Data Type and Variables
02. Data Type and Variables02. Data Type and Variables
02. Data Type and VariablesTommy Vercety
 
Introduction to Python (part 1/2)
Introduction to Python (part 1/2)Introduction to Python (part 1/2)
Introduction to Python (part 1/2)Silvia Tinena Coris
 
Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming LanguageExplore Skilled
 
Lesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticLesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticPVS-Studio
 
Python quick guide
Python quick guidePython quick guide
Python quick guideHasan Bisri
 

What's hot (20)

C programming perso notes
C programming perso notesC programming perso notes
C programming perso notes
 
A 64-bit horse that can count
A 64-bit horse that can countA 64-bit horse that can count
A 64-bit horse that can count
 
The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...
 
Loop structures chpt_6
Loop structures chpt_6Loop structures chpt_6
Loop structures chpt_6
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
Lecture no 1
Lecture no 1Lecture no 1
Lecture no 1
 
General Talk on Pointers
General Talk on PointersGeneral Talk on Pointers
General Talk on Pointers
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Python programming language
Python programming languagePython programming language
Python programming language
 
5. using variables, data, expressions and constants
5. using variables, data, expressions and constants5. using variables, data, expressions and constants
5. using variables, data, expressions and constants
 
C tutorial
C tutorialC tutorial
C tutorial
 
02. Data Type and Variables
02. Data Type and Variables02. Data Type and Variables
02. Data Type and Variables
 
Introducing Swift v2.1
Introducing Swift v2.1Introducing Swift v2.1
Introducing Swift v2.1
 
Introduction to Python (part 1/2)
Introduction to Python (part 1/2)Introduction to Python (part 1/2)
Introduction to Python (part 1/2)
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
 
Lesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticLesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmetic
 
Python
PythonPython
Python
 
Python quick guide
Python quick guidePython quick guide
Python quick guide
 

Viewers also liked

MzTEK Programming - Part 1
MzTEK Programming - Part 1MzTEK Programming - Part 1
MzTEK Programming - Part 1Becky Stewart
 
Auditory Display in MIR
Auditory Display in MIRAuditory Display in MIR
Auditory Display in MIRBecky Stewart
 
MzTEK Programming - Part 2
MzTEK Programming - Part 2MzTEK Programming - Part 2
MzTEK Programming - Part 2Becky Stewart
 
Intro to openFrameworks
Intro to openFrameworksIntro to openFrameworks
Intro to openFrameworksKyle McDonald
 
The Nature of Code via Cinder - Modeling the Natural World in C++
The Nature of Code via Cinder - Modeling the Natural World in C++The Nature of Code via Cinder - Modeling the Natural World in C++
The Nature of Code via Cinder - Modeling the Natural World in C++Nathan Koch
 
A Gentle Introduction to openFrameworks
A Gentle Introduction to openFrameworksA Gentle Introduction to openFrameworks
A Gentle Introduction to openFrameworksBecky Stewart
 

Viewers also liked (6)

MzTEK Programming - Part 1
MzTEK Programming - Part 1MzTEK Programming - Part 1
MzTEK Programming - Part 1
 
Auditory Display in MIR
Auditory Display in MIRAuditory Display in MIR
Auditory Display in MIR
 
MzTEK Programming - Part 2
MzTEK Programming - Part 2MzTEK Programming - Part 2
MzTEK Programming - Part 2
 
Intro to openFrameworks
Intro to openFrameworksIntro to openFrameworks
Intro to openFrameworks
 
The Nature of Code via Cinder - Modeling the Natural World in C++
The Nature of Code via Cinder - Modeling the Natural World in C++The Nature of Code via Cinder - Modeling the Natural World in C++
The Nature of Code via Cinder - Modeling the Natural World in C++
 
A Gentle Introduction to openFrameworks
A Gentle Introduction to openFrameworksA Gentle Introduction to openFrameworks
A Gentle Introduction to openFrameworks
 

Similar to MzTEK Programming - Part 3

Similar to MzTEK Programming - Part 3 (20)

FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
Basic calculator tutorial
Basic calculator tutorialBasic calculator tutorial
Basic calculator tutorial
 
03 Variables - Chang.pptx
03 Variables - Chang.pptx03 Variables - Chang.pptx
03 Variables - Chang.pptx
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdfconditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
 
10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx
 
Control All
Control AllControl All
Control All
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Cin and cout
Cin and coutCin and cout
Cin and cout
 
chap04-conditional.ppt
chap04-conditional.pptchap04-conditional.ppt
chap04-conditional.ppt
 
CalStatementsNAV2013
CalStatementsNAV2013CalStatementsNAV2013
CalStatementsNAV2013
 
loops.pdf
loops.pdfloops.pdf
loops.pdf
 
Ch3
Ch3Ch3
Ch3
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
 
9 cm604.12
9 cm604.129 cm604.12
9 cm604.12
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional Statements
 

Recently uploaded

PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsISCOPE Publication
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 

MzTEK Programming - Part 3

  • 1.
  • 3. To create a new list (to declare it): int[] x = new int[4];
  • 4. To create a new list (to declare it): what kind of things are in the list? i.e. how much space needs to be reserved for each item int[] x = new int[4];
  • 5. To create a new list (to declare it): what kind of things are in the list? i.e. how much space needs to be reserved for each item int[] x = new int[4]; [ ] means the data type is an array
  • 6. To create a new list (to declare it): what kind of things are in the list? i.e. how much space needs to be reserved for each item int[] x = new int[4]; [ ] means the data type is an array what is the name of the list?
  • 7. To create a new list (to declare it): what kind of things are in the list? i.e. how much space needs to be reserved for each item how long will the list be? int[] x = new int[4]; [ ] means the data type is an array what is the name of the list?
  • 9. put in a comparison statement (like < or >) if ( ) { } else { }
  • 10. put in a comparison statement (like < or >) if ( ) what to do if our comparison { statement is true } else { }
  • 11. put in a comparison statement (like < or >) if ( ) what to do if our comparison { statement is true } else { } what to do if our comparison statement is false
  • 12. put in a comparison statement (like < or >) if ( ) what to do if our comparison { statement is true } we don’t have to always have an else else { statement, sometimes you only care if the } statement is true what to do if our comparison statement is false
  • 13. What if we want to use multiple if statements? int counter; // some other code... if (counter < 10) { if (counter > 0 ) { counter++; } }
  • 14. What if we want to use multiple if statements? If counter is less than 10 and greater than 0, then int counter; increase counter by 1. // some other code... if (counter < 10) { if (counter > 0 ) { counter++; } }
  • 15. What if we want to use multiple if statements? If counter is less than 10 and greater than 0, then int counter; increase counter by 1. // some other code... if (counter < 10) { if (counter > 0 ) { counter++; } } counter is only increased if both if statements are true.
  • 16. What if we want to use multiple if statements? If counter is less than 10 and greater than 0, then int counter; increase counter by 1. // some other code... if (counter < 10) { if (counter > 0 ) { counter++; } } counter is only increased if These are called nested if both if statements are true. statements, because one is inside the { } of the other.
  • 17. What if we want to use multiple if statements? int counter; // some other code... if (counter > 10) { counter = 0; } if (counter < 0 ) { counter = 0; } }
  • 18. What if we want to use multiple if statements? If counter is greater than 10 or less than 0, then reset counter to 0. int counter; // some other code... if (counter > 10) { counter = 0; } if (counter < 0 ) { counter = 0; } }
  • 19. What if we want to use multiple if statements? If counter is greater than 10 or less than 0, then reset counter to 0. int counter; // some other code... if (counter > 10) { counter = 0; } if (counter < 0 ) { counter = 0; } } counter is reset if either if statements are true.
  • 20. BOOLEAN OPERATOR OR True OR False is False OR True is True OR True is False OR False is
  • 21. BOOLEAN OPERATOR OR True OR False is True False OR True is True OR True is False OR False is
  • 22. BOOLEAN OPERATOR OR True OR False is True False OR True is True True OR True is False OR False is
  • 23. BOOLEAN OPERATOR OR True OR False is True False OR True is True True OR True is True False OR False is
  • 24. BOOLEAN OPERATOR OR True OR False is True False OR True is True True OR True is True False OR False is False
  • 25. BOOLEAN OPERATOR OR True OR False is True False OR True is True When using OR in code, type || True OR True is True False OR False is False
  • 26. int counter; // some other code... if (counter > 10) { counter = 0; } if (counter < 0 ) { counter = 0; } }
  • 27. int counter; // some other code... if (counter > 10) { counter = 0; } if (counter < 0 ) { counter = 0; } int counter; } // some other code... if ((counter < 0) || counter > 10)) { counter = 0; }
  • 28. int counter; // some other code... if (counter > 10) { counter = 0; } if (counter < 0 ) { OR counter = 0; } int counter; } // some other code... if ((counter < 0) || counter > 10)) { counter = 0; }
  • 29. BOOLEAN OPERATOR AND True AND False is False AND True is True AND True is False AND False is
  • 30. BOOLEAN OPERATOR AND True AND False is False False AND True is True AND True is False AND False is
  • 31. BOOLEAN OPERATOR AND True AND False is False False AND True is False True AND True is False AND False is
  • 32. BOOLEAN OPERATOR AND True AND False is False False AND True is False True AND True is True False AND False is
  • 33. BOOLEAN OPERATOR AND True AND False is False False AND True is False True AND True is True False AND False is False
  • 34. BOOLEAN OPERATOR AND True AND False is False False AND True is False When using AND in code, type && True AND True is True False AND False is False
  • 35. int counter; // some other code... if (counter < 10) { if (counter > 0 ) { counter++; } }
  • 36. int counter; // some other code... if (counter < 10) { if (counter > 0 ) { counter++; } } int counter; // some other code... if ((counter > 0) && (counter < 10)) { counter++; }
  • 37. int counter; // some other code... if (counter < 10) { if (counter > 0 ) { counter++; AND } } int counter; // some other code... if ((counter > 0) && (counter < 10)) { counter++; }
  • 38. BOOLEAN OPERATOR NOT NOT True is NOT False is
  • 39. BOOLEAN OPERATOR NOT NOT True is False NOT False is
  • 40. BOOLEAN OPERATOR NOT NOT True is False NOT False is True
  • 41. BOOLEAN OPERATOR NOT NOT True is False NOT False is True When using NOT in code, type !
  • 42. int stopLoop = 0; // some other code... if(!stopLoop) { // some more code... }
  • 43. NOT int stopLoop = 0; // some other code... if(!stopLoop) { // some more code... }
  • 44. LOOPS There are two ways to repeat something: 1. Do this N number of times. 2. Keep doing this until something else happens.
  • 45. LOOPS There are two ways to repeat something: Repeat this event in 1. Do this N the calendar of number this times. many times. 2. Keep doing this until something else happens.
  • 46. LOOPS There are two ways to repeat something: Repeat this event in 1. Do this N the calendar of number this times. many times. 2. Keep doing this event in the Repeat this until calendar until a certain something else occurs. date happens.
  • 47. DO THIS N TIMES int i; for(i=0; i<4; i++) { }
  • 48. DO THIS N TIMES start with a number, in this case 0 int i; for(i=0; i<4; i++) { }
  • 49. DO THIS N TIMES start with a number, in if this statement is this case 0 true int i; for(i=0; i<4; i++) { }
  • 50. DO THIS N TIMES start with a number, in if this statement is this case 0 true int i; for(i=0; i<4; i++) { } then do whatever is written here
  • 51. DO THIS N TIMES start with a number, in if this statement is this case 0 true int i; for(i=0; i<4; i++) { } when you’ve done what’s then do whatever is in the { } once, do this, in written here this case add make i equal to its current value plus 1
  • 52. DO THIS N TIMES start with a number, in if this statement is true go back to see if the this case 0 middle statement is still int i; true for(i=0; i<4; i++) { } when you’ve done what’s then do whatever is in the { } once, do this, in written here this case add make i equal to its current value plus 1
  • 53. KEEP DOING THIS UNTIL SOMETHING ELSE HAPPENS while ( ) { }
  • 54. KEEP DOING THIS UNTIL SOMETHING ELSE HAPPENS if the statement here is true while ( ) { }
  • 55. KEEP DOING THIS UNTIL SOMETHING ELSE HAPPENS if the statement here is true while ( ) { } then do what is between { } once
  • 56. KEEP DOING THIS UNTIL SOMETHING ELSE HAPPENS if the statement here is true while ( ) { then repeat by checking the statement again } then do what is between { } once
  • 57. EXERCISE Write out each iteration of these loops and what the variables equal at the end of each loop. int i; int k = 100; int j = 15; while ( k > 0 ) { for (i=0; i<5; i++) { k = k -10; j = j * 2 - i; } }
  • 58. EXERCISE Go through code at http://processing.org/learning/basics/ embeddediteration.html • identify all of the variables, why were those data types chosen? • identify all of the comparisons made • identify all control structures • draw a diagram explaining what is happening in the code
  • 59. float box_size = 11; float box_space = 12; int margin = 7; size(200, 200); background(0); noStroke(); // Draw gray boxes for (int i = margin; i < height-margin; i += box_space){ if(box_size > 0){ for(int j = margin; j < width-margin; j+= box_space){ fill(255-box_size*10); rect(j, i, box_size, box_size); } box_size = box_size - 0.6; } }
  • 60. float box_size = 11; float box_space = 12; int margin = 7; size(200, 200); background(0); noStroke(); // Draw gray boxes for (int i = margin; i < height-margin; i += box_space){ if(box_size > 0){ for(int j = margin; j < width-margin; j+= box_space){ fill(255-box_size*10); rect(j, i, box_size, box_size); } box_size = box_size - 0.6; } }
  • 61. float box_size = 11; float box_space = 12; int margin = 7; size(200, 200); background(0); noStroke(); // Draw gray boxes for (int i = margin; i < height-margin; i += box_space){ if(box_size > 0){ for(int j = margin; j < width-margin; j+= box_space){ fill(255-box_size*10); rect(j, i, box_size, box_size); } box_size = box_size - 0.6; } }
  • 62. float box_size = 11; float box_space = 12; int margin = 7; size(200, 200); background(0); noStroke(); // Draw gray boxes for (int i = margin; i < height-margin; i += box_space){ if(box_size > 0){ for(int j = margin; j < width-margin; j+= box_space){ fill(255-box_size*10); rect(j, i, box_size, box_size); } box_size = box_size - 0.6; } }
  • 63. float box_size = 11; float box_space = 12; int margin = 7; size(200, 200); background(0); noStroke(); // Draw gray boxes for (int i = margin; i < height-margin; i += box_space){ if(box_size > 0){ for(int j = margin; j < width-margin; j+= box_space){ fill(255-box_size*10); rect(j, i, box_size, box_size); } box_size = box_size - 0.6; } }
  • 66. A function is something that can take input, do something, and then output something. input function output
  • 67. A function is something that can take input, do something, and then output something. input The input and output are optional, some functions do not have both. function output
  • 68. A function is something that can take input, do something, and then output something. input The input and output are optional, some functions do not have both. function Functions exist so that you don’t have to output write a lot of code.
  • 69. When you call the function size( ) size(300, 400);
  • 70. When you call the function size( ) it creates a window with the size(300, 400); parameters you entered
  • 71. When you call the function size( ) it creates a window with the size(300, 400); parameters you entered and then the program continues with the next line of code.
  • 72. When you call the function size( ) it creates a window with the size(300, 400); parameters you entered and then the program continues with the next line of code. It has a return type of void, so there’s nothing given back directly to your program, but it does some work for you. It created the window.
  • 73. When you call the function size( ) it creates a window with the size(300, 400); parameters you entered and then the program continues with the next line of code. It has a return type of void, so there’s nothing given back directly to your program, but it does some work for you. It created the window. In Processing, (as far as I know) all functions have a void return type.
  • 74. void means that nothing is returned.
  • 75. void means that nothing is returned. void setup( ) { }
  • 76. void means that nothing is returned. void setup( ) { is typed when you want to have something happen between { }. }
  • 77. void means that nothing is returned. void setup( ) { is typed when you want to have something happen between { }. } The void in front of setup means nothing is returned after setup( ) is finished.
  • 78. In Arduino: int val = 0; int inPin = 7; val = digitalRead(inPin);
  • 79. In Arduino: int val = 0; int inPin = 7; val = digitalRead(inPin); function name
  • 80. In Arduino: input parameters and int val = 0; type int inPin = 7; val = digitalRead(inPin); function name
  • 81. In Arduino: input parameters and int val = 0; type int inPin = 7; val = digitalRead(inPin); function name an int is returned, so it needs to be stored somewhere
  • 83. Create a Processing program that generatively draws depending on the mouse position. void setup() { // create the window size(400, 400); Within your program use: } • Variables void draw() { // set the colour • For or while loop fill(10, 10, 255); • If or if/else // draw the circle ellipse(mouseX, mouseY, 100, 100); Start with this code. }