SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
From last time…
•

Libraries, Functions, Active Mode, Interaction!

•

Check the site for a list of inspiration sources!

•

We have a Teaching Assistant:!

! Yifan Wang, yifan@cise.ufl.edu!
! Office Hours: CSE309, 2:00pm–3:00pm
Variables

CAP
What is a variable?
•

An address in memory: 0x0000883A!

•

Variables have a type and a name!

int x;
int y;
float weight;
string introduction;
Memory
int x;
The Primitives
boolean!! ! true or false!
char! ! ! ! ‘a’ ‘b’ ‘c’!
byte! ! ! ! -128 to 127
short! ! ! -32,768 to 32,767!
int ! ! ! -2147483648 to 2147483647!
long! ! ! ! larger numbers!!
float! ! ! 3.14159!
double! ! ! float with more decimal places
Common Primitives
boolean!! ! true or false!
int ! ! ! -2147483648 to 2147483647!
float! ! ! 3.14159
Using Variables
1. Declare the variable!

int xposition;

// type name;

2. Initialize the variable!

xposition = 10;

// name = value;
Using Variables
1 & 2. Declare & Initialize the variable!

int xposition = 10;
// type name = value;
Demo Variables
System Variables
mouseX, mouseY
pmouseX, pmouseY
width, height

// sketch dimensions

frameCount, frameRate
displayWidth, displayHeight
dimensions

// screen

key, keyCode, keyPressed
mousePressed

// is it pressed?

mouseButton

// left/center/right
Demo!
System Variables
random() & casting
random(j)

// from 0 to j

random(j,k)

// from j to k

float r = random(24);
int r = random(24);

// needs to be cast!

int r = int(random(24));

// int() method

int r = (int) random(24); // Java cast
For next time…
•

Monday is Martin Luther King, Jr. Day!

•

Read Shiffman, p. 59–70 (Conditionals I)!

•

Project Proposals due on Wed, January 22

Quiz
•

Closed book, 25 minutes, good luck!

Weitere ähnliche Inhalte

Andere mochten auch

rory reyes
rory reyesrory reyes
rory reyesmamayay
 
15. Final Project - Iteration 1
15. Final Project - Iteration 115. Final Project - Iteration 1
15. Final Project - Iteration 1Joseph Murphy
 
How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)
How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)
How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)Sergio Manuel Frías
 

Andere mochten auch (9)

La brújula
La brújulaLa brújula
La brújula
 
Adachris
AdachrisAdachris
Adachris
 
7. Conditionals II
7. Conditionals II7. Conditionals II
7. Conditionals II
 
rory reyes
rory reyesrory reyes
rory reyes
 
2. Processing
2. Processing2. Processing
2. Processing
 
Evaluation 4
Evaluation 4Evaluation 4
Evaluation 4
 
15. Final Project - Iteration 1
15. Final Project - Iteration 115. Final Project - Iteration 1
15. Final Project - Iteration 1
 
How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)
How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)
How to reuse old objects by 4th 1st EES N ° 4 (Frías Sergio & Décimo Sebastián)
 
Evaluation 2
Evaluation 2Evaluation 2
Evaluation 2
 

Mehr von Joseph Murphy

Mehr von Joseph Murphy (20)

33. Input II
33. Input II33. Input II
33. Input II
 
32. Input I
32. Input I32. Input I
32. Input I
 
30. Text II
30. Text II30. Text II
30. Text II
 
29. Text I
29. Text I29. Text I
29. Text I
 
28. Video II
28. Video II28. Video II
28. Video II
 
27. Video I
27. Video I27. Video I
27. Video I
 
26. Images II
26. Images II26. Images II
26. Images II
 
25. Images I
25. Images I25. Images I
25. Images I
 
24. Translation & Rotation II
24. Translation & Rotation II24. Translation & Rotation II
24. Translation & Rotation II
 
23. Final Project Iteration II
23. Final Project Iteration II23. Final Project Iteration II
23. Final Project Iteration II
 
34. Final Project Iteration 3
34. Final Project Iteration 334. Final Project Iteration 3
34. Final Project Iteration 3
 
22. Translation & Rotation I
22. Translation & Rotation I22. Translation & Rotation I
22. Translation & Rotation I
 
21. Mathematics II
21. Mathematics II21. Mathematics II
21. Mathematics II
 
20. Mathematics I
20. Mathematics I20. Mathematics I
20. Mathematics I
 
A. Design Thinking Lecture
A. Design Thinking LectureA. Design Thinking Lecture
A. Design Thinking Lecture
 
18. Algorithms
18. Algorithms18. Algorithms
18. Algorithms
 
14. Arrays I
14. Arrays I14. Arrays I
14. Arrays I
 
13. Objects II
13. Objects II13. Objects II
13. Objects II
 
12. Objects I
12. Objects I12. Objects I
12. Objects I
 
10. Function I
10. Function I10. Function I
10. Function I
 

Kürzlich hochgeladen

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Kürzlich hochgeladen (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

5. Variables

  • 1. From last time… • Libraries, Functions, Active Mode, Interaction! • Check the site for a list of inspiration sources! • We have a Teaching Assistant:! ! Yifan Wang, yifan@cise.ufl.edu! ! Office Hours: CSE309, 2:00pm–3:00pm
  • 3. What is a variable? • An address in memory: 0x0000883A! • Variables have a type and a name! int x; int y; float weight; string introduction;
  • 5. The Primitives boolean!! ! true or false! char! ! ! ! ‘a’ ‘b’ ‘c’! byte! ! ! ! -128 to 127 short! ! ! -32,768 to 32,767! int ! ! ! -2147483648 to 2147483647! long! ! ! ! larger numbers!! float! ! ! 3.14159! double! ! ! float with more decimal places
  • 6. Common Primitives boolean!! ! true or false! int ! ! ! -2147483648 to 2147483647! float! ! ! 3.14159
  • 7. Using Variables 1. Declare the variable! int xposition; // type name; 2. Initialize the variable! xposition = 10; // name = value;
  • 8. Using Variables 1 & 2. Declare & Initialize the variable! int xposition = 10; // type name = value;
  • 10. System Variables mouseX, mouseY pmouseX, pmouseY width, height // sketch dimensions frameCount, frameRate displayWidth, displayHeight dimensions // screen key, keyCode, keyPressed mousePressed // is it pressed? mouseButton // left/center/right
  • 12. random() & casting random(j) // from 0 to j random(j,k) // from j to k float r = random(24); int r = random(24); // needs to be cast! int r = int(random(24)); // int() method int r = (int) random(24); // Java cast
  • 13. For next time… • Monday is Martin Luther King, Jr. Day! • Read Shiffman, p. 59–70 (Conditionals I)! • Project Proposals due on Wed, January 22 Quiz • Closed book, 25 minutes, good luck!