SlideShare une entreprise Scribd logo
1  sur  83
Télécharger pour lire hors ligne
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.      }

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à Declare and Initialize an Integer Array in Java

Similaire à Declare and Initialize an Integer Array in Java (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
 

Dernier

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 

Dernier (20)

Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 

Declare and Initialize an Integer Array in Java

  • 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. }