CompSci 4 Chap 9 Sec 1 October 28, 2010 Prof. Susan Rodger.

Slides:



Advertisements
Similar presentations
Getting Started With Alice: The Basics By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Advertisements

Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Events Chapter 7. Interactivity The real world is interactive User determines order of actions instead of programmer.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
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.
Alice Learning to program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Methods Tutorial: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 9, 2008.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Shorter of two objects and changing color Functions, events and setting the color Susan Rodger, Duke University June 2008.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
CompSci 4 Chap 5 Sec 1 Oct 13, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
Getting started with Alice Adapted from presentations by Jenna Hayes, Duke University Donna Gavin, UWP Computer Science and Software Engineering.
Poses Tutorial Alex Boldt Under the direction of Professor Susan Rodger Duke University July 2015.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
CompSci 4 Chap 8 Sec 1 Nov 17, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
Methods Tutorial: Part Two By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Lists Tutorial By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
CS320n – Elements of Visual Programming Lists Mike Scott (Slides 9-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
CompSci 4 Chap 5 Sec 2 Oct 18, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Can I get your number? By Melissa Dalis Professor Susan Rodger Duke University June 2011.
CompSci 4 Chap 4 Sec 1 Sept 15, 2005 Prof. Susan Rodger.
The Essentials of Alice (Bunny) By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Illuminating Computer Science CCIT 4-6Sep
Nonvisual Arrays by Chris Brown under Prof. Susan Rodger Duke University June 2012.
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.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
Learning to Program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
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.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
CompSci 4 Chap 5 Sec 2 Oct 9, 2008 Prof. Susan Rodger.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Creating a Fancier Chicken to use in several worlds - Inheritance Susan Rodger Duke University June 2009.
CompSci 4 Chap 5 Sec 1 and 2 Oct 14, 2010 Prof. Susan Rodger.
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Lesson 8C Animation and Events. Step 3: Animation Drag it into the method and have him say “let her go!” Click on the knight in the object tree and scroll.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
CompSci 4 Chap 10 November 4, 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.
How Tall Are You? Introducing Functions for Alice 3 By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made.
Getting Started With Alice: The Basics. Step 1: Background Open up Alice, and choose a background for your Alice world. Your world is something you can.
The Essentials of Alice (Bunny)
Getting Started With Alice: The Basics
Professor Susan Rodger
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Changing Color, Using Text Objects, and Random Selection in Alice
Lists Alice.
Lists Alice.
Methods Tutorial: Part Two
Lists Alice.
Lists Alice.
Getting Started With Alice: The Basics
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Presentation transcript:

CompSci 4 Chap 9 Sec 1 October 28, 2010 Prof. Susan Rodger

Announcements Read Chapter 9, Sec 2 for next time Assignment 6 due Thursday, Nov 4 Today –Chapter 9, Section 1 – Lists

Collections 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 skeletons

Create List (cont) Type in name Select type Select “make a list” Add skeletons 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 Order For each skeleton in order skeleton says “Boo” For each skeleton in order skeleton turns its head around

Applying a Part of an object Drag in skeleton turn Select part Drag over part Drag in item Type in part (must spell correctly!)

Example/Demo: Iteration Together For all skeleton together skeleton says “Boo” For all skeleton in together skeleton turns its head and neck around

Add in a girl Her parts are almost the same to the head. Rename “body” part to “upperBody” Add her to the list and click “Play”

Add in MadScientist His parts are not the same structure as the skeleton, cannot be renamed to match. What happens if we put him in the list and Play? Note: Alice bug – cannot delete from a list

Selecting an item from a list You can select a random item or a specific item from a list. This code makes a particular skeleton jump Suppose we want to have one item from our list (chosen randomly) to jump up and down. How would we do that?

List Questions What are differences between For all in order and For all together? Why is the list a world variable? 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? What type of method can you not put in a For all in order or For all together?

Classwork today Create a list of players Make them do several things (See handout).

Solution to having a random object from a list jump Add a variable called jumper Drag over and set the variable “jumper” to skeleton temporarily

Solution (cont) Drag over the list scaryThings and drop it on skeleton. You can choose which item in the list. Select “random item from list”

Solution (cont) Then change “skeleton” in the move commands to “world.jumper” Play a random object from your list will jump each time this code executes.