Class 8 - Lists and Arrays Matthew Hashim Click to edit...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
12/4/09 Click to edit Master subtitle style Lists and Arrays Matthew Hashim 9/17/2009 11
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Goals n Use a list to store multiple items n Use Alice’s forAllInOrder and forAllTogether statements 22
Background image of page 2
MGMT 290D 12/4/09 Lists and Arrays n Some variables only store a single value ¨ Number , Boolean , String , Object , Sound , Color n Variables that can store multiple values ¨ list: container that can dynamically grow and shrink ¨ array: container whose size remains fixed at run-time n Benefits of using variables that store multiple values ¨ Reduces amount of code that needs to be written ¨ Makes a program more readable n Example: a variable playList that holds 12 songs ¨ Pass all 12 songs to a method using one parameter 33
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Lists and Arrays (continued) 44
Background image of page 4
MGMT 290D 12/4/09 List Example 1: Flight of the Bumble Bees n Scene 2: a dozen bees rise to defend queen’s honor ¨ Set up the scene by adding 12 bee s and 1 queenBee n Manipulating 12 individual bees leads to inefficiencies n Adding 12 bees to a list simplifies implementation ¨ Form: Object[]bees = bee, bee2,. .. bee12; n Defining bees list variable in playScene2() ¨ Open Create New Local Variable dialog box ¨ Select Object type and then make a List ¨ Click new item and add the first bee to the list ¨ Continue adding new items until the list holds 12 bees 55
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 List Example 1: Flight of the Bumble Bees (continued) 66
Background image of page 6
MGMT 290D 12/4/09 List Example 1: Flight of the Bumble Bees (continued) 77
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/04/2009 for the course MGMT 290 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 22

Class 8 - Lists and Arrays Matthew Hashim Click to edit...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online