Bootcamp - Team TEAL - Day 9
Upcoming SlideShare
Loading in...5
×
 

Bootcamp - Team TEAL - Day 9

on

  • 929 views

arrays and looping through arrays with for loops!

arrays and looping through arrays with for loops!

Statistics

Views

Total Views
929
Views on SlideShare
474
Embed Views
455

Actions

Likes
0
Downloads
3
Comments
0

1 Embed 455

http://bootcamp.parsons.edu 455

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Bootcamp - Team TEAL - Day 9 Bootcamp - Team TEAL - Day 9 Presentation Transcript

  • TEA M TEAL LIZ RUTLEDGEDAY 9 rutle173@newschool.eduAugust 11, 2011 esrutledge@gmail.com
  • agenda. Review: Learn: whatever you want. ARRAYS!!! (double-woooooooot!) likely candidates: namely: custom functions controlling a bunch of things for loops individually without having to write an entirely separate code if statements sequence for each one mouse/keyboard interaction boolean “switches” also: looping through arrays with a for loopDAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011
  • homework brainstorming! questions? mind-blowing discoveries? new-found life goals? http://vimeo.com/21651041DAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011
  • arrays! storing lots of little things in one bigger list of things. the concept: being able to store lots of related variables in one place so that you can easily modify or control all those objects simultaneously portability: way easier to control a million little shapes if they’re all accessbile through the same array readability: by keeping all your variables of a certain kind in one place it’s easier to tell what you’re dealing with throughout the code (and easier to remember variable names!) scalability: you can increase the number of elements controlled by your arrays by changing a single numberDAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011
  • how arrays work. a quick example. // define list of grocery items to pick up at store as separate this: variables String grocery1 = “beer”; String grocery2 = “milk”; String grocery3 = “bread”; String grocery4 = “eggs”; String grocery5 = “chocolate”; // define list of grocery items to pick up at store as items in an array String[] = new String[5]; turns groceries[0] = “beer”; groceries[1] = “milk”; into groceries[2] = “bread”; this: groceries[3] groceries[4] = = “eggs”; “chocolate”;DAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011
  • how arrays work. a quick example. except now we can refer to ALL of our groceries at once: println(grocery1); this println(groceries); println(grocery2); println(grocery3); // prints to the println(grocery4); console: vs. println(grocery5); [0] “beer” [1] “milk” // prints to the console: [2] “bread” beer [3] “eggs” milk [4] “chocolate” bread eggs this chocolateDAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011
  • arrays and for loops. putting that handy index to work. the concept: looping through all the elements of an array in english please? remember how for loops increment through numbers? and how arrays are indexed by numbers? not a coincidence. we can use those same incrementing loops to do things to every element in an array with very little effort!DAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011
  • arrays and for loops. putting that handy index to work. example: looping through all the elements of an array for( int i = 0; i < 5; i++) { print(groceries[i]); this } println(grocery1); println(grocery2); vs. // prints to the console: println(grocery3); beer println(grocery4); milk println(grocery5); bread eggs the // prints to the console: chocolate beer old milk way bread eggs chocolateDAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011
  • homework. due Friday, August 12th. more bouncing ball[z]! Redo your bouncing ball(s) sketch using arrays to create 50 bouncing balls. The balls should have different sizes, colors, and speeds. (it’s okay if some overlap but no two balls should be exactly alike.) extra credit: make each ball change color (independently) when it hits a surface and bounces extra extra credit: store how many times each ball has bounced off a surface in another array (hint: if you print out that array, faster moving balls should have a higher number of bounces)DAY 9Tuesday, 11 Aug 2011 CODE bootcamp 2011