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
Serving as a Club Consultant 0. Consultant: 1 2 Session Objectives.
Advertisements

Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Class-level Methods and Inheritance Part 1 Alice.
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.
Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.
Parameters Section 8-8 Web Design. Objectives The student will: Understand what a parameter is Understand how to use a parameter in Alice Understand how.
Introducing While loops (and random numbers too) Alice.
Arrays and Array Visualization
Tips & Techniques 6 Random Numbers and Random Motion Alice.
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.
Classes, Objects, and World-level Methods Alice. Programming in Alice© 2006 Dr. Tim Margush2 Class / Object Class A template describing the characteristics.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
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.
Parameters and Event-Handler Methods Alice. Mouse clicks Interactive programs often allow the user to mouse click an object in the display. buttons in.
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.
What we will do today Learn about functions in Alice.
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
Programming: Simple Control Structures Part 2 – Repetition Alice.
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 Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
Alice 3.0 A Guided Tour Mike R-D YRDSB. Agenda General Walkthrough of Alice 3.0 Loops, Variables, Threads Methods / Properties Arrays Misc.
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.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
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.
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.
Parameters Alice. Overview The need for more flexible methods Passing a parameter to a method Demos Using the Alice interface to write code for a parameter.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
CompSci 4 Chap 10 Nov 22, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
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
Functions Sec 51 Web Design.
Arrays and Array Visualization
Variables and Inheritance Part 2
Functions Sec 8-11 Web Design.
Parameters Alice.
Class-level Methods Alice.
Procedures.
Lists Alice.
Lists Alice.
List Search Alice.
Parameters and World-level methods
Lists Alice.
Variables and Inheritance Part 1
Functions Alice.
Lists Alice.
Tutorial for Arrays and Lists
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.
Class-level Methods and Inheritance
Functions 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) Major benefit -- we can write program code for all the objects in the group (rather than separate code for each object).

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 a collection of objects or information. We call the organizing structure 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.

Initial World First, create an initial world with five Rockette objects. The chorus line performs many dance movements in coordination. This is an animation where a list of objects would be useful.

Creating a list: Step 1 After the objects have been added to the initial world, a list can be created. The first step in creating a list is to create a new world- level variable. (Why should it be world-level rather than class-level?)

Creating a list: Step 2 In the dialog box, type in a name select Object type check “make a List” box click new item button 5 times to specify each of the 5 rockettes (each item we wish to include in the list must be added to the list)

Programming with a list Now that a list has been created, how do we make use of it 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." Iteration can be done in order (one at a time) all together (simultaneously)

Iterating through a list The two iterative loops: in order (one at a time) all together (simultaneously)

Example: Iteration in Order A typical chorus line dance move involves each dancer (one after the other) kicking up their right 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

kickUpRightLeg The whichRockette parameter allows you to pass in the specific rockette who is performing the action.

Demo: Calling the method with a list What would happen if rockette4 had been first in the list? Try it out!

Demo: Iterating all together Note that the kickUpRightLeg method is still the same. All we did was call the method from within a For all together iterative loop.

Lists wrap-up What are the differences between For all in order and For all together? What are examples of cases where you might want to use For all in order? What are examples of cases where you might want to use For all together?

Assignment Read Chapter 9-1, Lists Lab 9-1