DOC PREVIEW
Duke CPS 004 - Chap 10 Sec 2

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 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 18 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 18 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 18 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 18 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 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CompSci 4Chap 10 Sec 2Apr 21, 2005Prof. Susan RodgerNote: thanks to Wanda Dann and Steve Cooper for slide ideasAnnouncements• Next time Demos and review• Be A UTA for CPS 4 – Fall 2005• Research study – id number emailed to you this weekFinal Exam• Alice book Chaps 1-2,4-10• Mix of MC, short answer, write code for a function or method• No html on final• Closed book, closed notes• Will give you a list of properties, methods and functions for an objectFinal Exam – Time,Date• Final exam is Saturday, May 7, 2-5pm• Alternate exam times (must sign up)– Monday, May 2, 2-5pm– Wednesday, May 4, 2-5pmWhat we will do today• Lecture on Chap 10, Sec 2– Arrays, an ordered list– ArrayVisualization• ClassworkWhat is an array?•An array is a collection of objects or information organized in a specific order• The individual components (elements) are of the same type (all object or all number, etc.)• Analogy – Music CD– Collection of songs listed in order– CD player allows you to• Play songs in order• Play songs by specifying its number• Play songs in random orderArrays in Alice• In Alice, array is a data structure to organize objects or information• An array is not visible, it is a way of organizing• But….– Alice has a 3D model to help you “see” the arrayExample – Create a visualization of an array of people• Add 5 people to the world• Add an array visualization• Not an array yet, must add people to the array• Positions in array numbered starting with 0Initialize array - Add Alice to Array in position 0• Alice automatically moves to the 0 position!Add Soldier to the Array• Soldier moves automatically to position 1 (which is the 2cd position)!Add RandomGuy, Skater and Rockette• The array initialization is complete!• Set isVisible for arrayVisualization to false– Array not seenSetting elements in array• Objects in an array are called elements• Use “let” to set a position in an array• Using “let”.Accessing elements in an array• Can specify an element at a particular location in the arrayRepeat for all items in the array –in order• Use “loop” – complicated version• Note: index in loop is used in body• What does this do?• What does this do?Array vs. List• Array– Elements are ordered– Can access a particular element – 3– Use “Loop” - loop over elements – one at a time, OR every second element, etc•List– Elements are not ordered– Use “For all in order”, “For all together” – does something to each element in the list – just don’t know the order this occursClasswork today – Sorting animals• Fix setup – add one line• Now tennisball6 is to the right of tennisballClasswork (cont)• AnyBallToRight obj Ball– Use “For all in order”– Compare Ball to each ball in the list– Ball and ball comparing to must both be yellow (active)– If there is any ball to the right of Ball return true– Return false at the end, only checking all balls in the list.Classwork (cont)• rightMostBall• Use “For all in order”– Check each ball in the list. If there is a ball that does not have any ball to the right of it, then return that ball.– There is only one active ball that does not have an active ball to the right of


View Full Document

Duke CPS 004 - Chap 10 Sec 2

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 10 Sec 2
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 10 Sec 2 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 10 Sec 2 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?