{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right Arrow Icon
MGMT 290D 12/4/09 Lists and Arrays (continued) 44
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
Image of page 5

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

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

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern