Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.

Slides:



Advertisements
Similar presentations
Class-level Methods and Inheritance Part 1 Alice.
Advertisements

Review of Chapter 4 Sections 1 and 2 World-level methods involve two or more objects break a large problem into smaller, logical units follow a design.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
Introducing While loops (and random numbers too) Alice.
Arrays and Array Visualization
Recursion Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we know is that repetition.
Fall 2007ACS-1805 Ron McFadyen1 Ch 9 Lists In some animations, several objects must perform the same actions Example: A marching band, where the band members.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Creating An Animation Program Alice Web Design Section 8-4.
Today’s Agenda 1.Collect Pre-Lab 4 2.Alice Programming Assignment Storyboards 3.Classes 4.Objects 5.Methods 6.Assign pair programming teams and meet upstairs.
Tutorial for Arrays and Lists By Ruthie Tucker. Description This presentation will cover the basics of using Arrays and Lists in an Alice world This presentation.
Arrays and Array Visualization Alice. What is an array? An array is a collection of objects or information that is organized in a specific order. The.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
Variables and Inheritance A More Complex Example Alice.
Writing Our Own Functions Alice. Functionality A function receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Functions Alice.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Variables and Inheritance Part 1
CS320n – Elements of Visual Programming Lists Mike Scott (Slides 9-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Variables and Functions Alice. Naming is Important If you get a new pet one of the first things you do is name it Gives you a way to refer to the new.
Functions Sec 8-11 Web Design. Objectives The Student will: Understand what a function is Know the difference between a method and a function Be able.
Programming: Simple Control Structures
Questions Alice. Functionality A question receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
World-level Classes Chapter 6 Part 2. Programs Grow Program code grows larger over time This makes it more difficult to read and process the code in our.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
List Search Alice. Common Uses of Lists Iterating through a list of several like items to accomplish the same task with each item. As in the previous.
CompSci 4 Chap 9 Sec 1 October 28, 2010 Prof. Susan Rodger.
Parameters Alice. A beetle band Our task is to create an animation for a bug band as an advertisement for their next concert.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Variables and Inheritance Part 1 Alice. Review: Properties A class defines properties for its own kind of object. When an object is created (instantiated),
Xin Liu Dec 1, Sound Open lab6.a2w Import horseneigh.wav as a property Add the method “play sound” to horse.neigh Exercise Create a class-level.
Lists and Iteration in Alice
Parameters Section 8-8 Web Design.
Functions Sec 51 Web Design.
Arrays and Array Visualization
Recursion Alice.
While: Indefinite Loops
Functions Sec 8-11 Web Design.
Recursion Alice.
Parameters Alice.
Programming: Simple Control Structures
Lists Alice.
Lists Alice.
List Search Alice.
Programming: Simple Control Structures
Parameters and World-level methods
Programming: Simple Control Structures
Programming: Simple Control Structures
Lists Alice.
Variables and Inheritance Part 1
Functions Alice.
Lists Alice.
Programming: Simple Control Structures
Execution Control with If/Else and Boolean Questions Example: Multiple Conditions Alice.
List Search Alice.
Ch 9 Lists In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing the same.
Parameters Alice.
Functions Alice.
Programming: Simple Control Structures
Class-level Methods and Inheritance
Functions Alice.
Execution Control with If/Else and Boolean Questions Example: Multiple Conditions Alice.
Execution Control with If/Else and Boolean Questions Example: Multiple Conditions Alice.
Functions Alice.
Variables and Inheritance A More Complex Example
Presentation transcript:

Lists Alice

Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing the same marching steps. In such situations, it is convenient to collect all the objects into a group (a collection)

List One way to organize objects into a collection is to use a list. In our daily lives, we use lists to help us organize things. For example, assignments list shopping list In programming, a list is known as a data structure.

Types of Lists In Alice, a list can be a list of numbers or a list of objects, colors, or other type …. In this session, we will use an example of a list of objects.

Example The famous Rockettes ® are preparing for their winter holiday show. You have been hired to create an animation for the holiday show that will be used on a web site where people can purchase tickets for the show.

Creating a list: Step 1 Create the initial world and add five rockette objects to the world. Then, create a new world- level variable in the properties panel. (Why should it be world-level rather than class-level?)

Creating a list: Step 2 In the popup dialog box, type in a name select Object type check “make a List” box click new item button 5 times to select each of the 5 rockettes, one at a time

Programming with a list Now that a list has been created, how do we use the list in a program? One of the most useful operations with a list is to repeatedly perform some action with each item in the list. We call this iteration or "iterating through a list."

Iterating through a list Iteration can be done in two ways: in order (one at a time) all together (simultaneously)

Example: Iteration in Order A typical chorus line dance involves each dancer (one after the other) kicking up one leg. Possible storyboard: For all dancers in order item_from_dancers kickUpRightLeg kickUpRightLeg Parameter: whichRockette Do in order Do together whichRockette right thigh turn back whichRockette right calf turn forward whichRockette right calf turn back

Demo Ch09Lec1Rockette-V1 Concepts illustrated in this example A method that defines an action to be performed by objects in a list is a world-level method (it involves more than one object). In this example, kickUpRightLeg The For all in order statement traverses the list, one list item at a time.

Demo Ch09Lec1Rockettes-V2 Concepts The For all together statement executes the action for all list items simultaneously. The kickUpRightLeg method is still the same. All we did was call the method from within a For all together iterative loop.

Assignment Read Chapter 9 Section 1, Lists

Lab Chapter 9 Lecture 1 Lab