DOC PREVIEW
Duke CPS 004 - Chap 9 Sec 1

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CompSci 4Chap 9 Sec 1 Nov 3, 2005Prof. Susan RodgerNote: thanks to Wanda Dann and Steve Cooper for slide ideasAnnouncements• Read Chapter 9, Sec 2 for next time• Assignment 6 due TuesdayWhat we will do today• Lecture on Chap 9, Sec 1– Lists• ClassworkCollections• In some animations, several objects must perform the same actions– Example: marching band marching• It is convenient to collect all objects into a group (collection)– Major benefit – write code for all the objects in the group (rather than separate code for each object)List• A list - one way to organize objects into a collection– You may use lists to organize• Shopping list• Todo list• In programming, a list is a collection of objects or information. We call an organizing structure a data structure.Creating Lists• In Alice, a list can be a list of numbers, or a list of objects, or a list of colors, etc.• Let’s create a list of chickensCreate List (cont)• Type in name• Select type• Select “make a list”• Add chickens to list (click “new item” 4 times)•Result is:Programming with a List• Can “iterate through a list”– Do something to each item in the list• In order (use “For all in order”)• All together (use “For all together”)Example/Demo: Iteration in OrderFor each chicken in orderchicken says “hello”For each chicken in orderchicken turns its head and neck aroundApplying a Part of an object• Drag in chicken turn• Select part• Drag over part• Drag in item• Type in partExample/Demo: Iteration TogetherFor all chicken togetherchicken says “hello”For all chicken in togetherchicken turns its head and neck aroundList Questions• What are differences between For all in order and For all together?• When would you want to use each of them?• What can you put in a list?• When can you refer to a part of an object in a list?Classwork today• Create a list of players • Make them do several


View Full Document

Duke CPS 004 - Chap 9 Sec 1

Documents in this Course
Lecture

Lecture

18 pages

Chapter 7

Chapter 7

18 pages

Chapter 9

Chapter 9

15 pages

Java 1

Java 1

24 pages

Java 3

Java 3

11 pages

Lecture

Lecture

10 pages

Chapter 4

Chapter 4

28 pages

Chap 2

Chap 2

16 pages

Graphics

Graphics

20 pages

Lecture

Lecture

12 pages

HTML

HTML

16 pages

Java 1

Java 1

6 pages

Chapter 4

Chapter 4

16 pages

The Plan

The Plan

25 pages

Lecture

Lecture

16 pages

Chapter 6

Chapter 6

21 pages

Lecture

Lecture

18 pages

Lecture

Lecture

23 pages

Lecture

Lecture

16 pages

Lecture

Lecture

19 pages

Lecture

Lecture

12 pages

Lecture

Lecture

5 pages

Lecture

Lecture

26 pages

Lecture

Lecture

16 pages

Chapter 7

Chapter 7

23 pages

Lecture

Lecture

21 pages

Lecture

Lecture

4 pages

Lecture

Lecture

4 pages

Lecture

Lecture

8 pages

Lecture

Lecture

4 pages

Lecture

Lecture

10 pages

Chapter 4

Chapter 4

32 pages

Java

Java

4 pages

CompSci 4

CompSci 4

18 pages

Lecture

Lecture

26 pages

CompSci 4

CompSci 4

12 pages

HTML

HTML

17 pages

Lecture

Lecture

16 pages

Chapter 5

Chapter 5

22 pages

Lecture

Lecture

4 pages

Chapter 4

Chapter 4

10 pages

Chapter 2

Chapter 2

15 pages

Chapter 8

Chapter 8

14 pages

Lecture

Lecture

15 pages

Load more
Download Chap 9 Sec 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Chap 9 Sec 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chap 9 Sec 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?