Parameters Alice.

Slides:



Advertisements
Similar presentations
As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)?
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.
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.
Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.
Parameters Alice.
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.
Arrays and Array Visualization
More About Recursion Alice. A second form of recursion A second form of recursion is used when the solution to a problem depends on the ability to break.
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.
Animation Programs: Scenarios and Storyboards Alice.
Variables and Inheritance A More Complex Example 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.
Programming: Simple Control Structures Part 2 – Repetition Alice.
Interactive Programming Alice. Control of flow Control of flow -- how the sequence of actions in a program is controlled. What action happens first, what.
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.
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.
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.
Parameters MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project funded.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Parameters Section 8-8 Web Design.
Classes, Objects, and World-level Methods
Functions Sec 51 Web Design.
Arrays and Array Visualization
Functions Sec 8-11 Web Design.
Parameters Alice.
Programming: Simple Control Structures
Lists Alice.
Parameters and Event-Handler Methods
Lists Alice.
Creating an Animation Program
Classes, Objects, and World-level Methods
List Search Alice.
Programming: Simple Control Structures
Parameters and World-level methods
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Interactive Programming
Programming: Simple Control Structures
Programming: Simple Control Structures
Lists Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Parameters and Event-Handler Methods
Variables and Inheritance Part 1
Functions Alice.
Parameters and Event-Handler Methods
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Lists Alice.
Programming: Simple Control Structures
More About Recursion Alice.
List Search Alice.
Functions Alice.
Programming: Simple Control Structures
Creating An Animation Program
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Class-level Methods and Inheritance
Parameters and Event-Handler Methods
Interactive Programming
Functions Alice.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Functions Alice.
Class-level Methods and Inheritance Part 2
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Variables and Inheritance A More Complex Example
Presentation transcript:

Parameters Alice

A beetle band Our task is to create an animation for a bug band as an advertisement for their next concert.

Storyboards Each bug band member will perform a solo. Do together Do in order georgeBeetle move up georgeBeetle move down play sound Do together Do in order ringoBeetle move up ringoBeetle move down play sound Do together Do in order paulBeetle move up paulBeetle move down play sound Do together Do in order lennonBeetle move up lennonBeetle move down play sound

Demo Ch04Lec2BeetleBand-v1 Concepts illustrated To play a sound, a sound file must first be imported into Alice. (Alice is not a sound editor.) This code is only for georgeBeetle. Three more methods (one for each band member) will be needed!

A Better Solution Four versions of very similar code seems a bit tedious. The only things that change are the beetle and the music that plays. A better solution is to write a more flexible method.

Parameters Built-in methods provide flexibility by providing parameters such as distance and direction. Parameters allow you to pass in values (arguments). Example Parameters: distance, direction Arguments: 0.5 meters, 0.5 seconds

Kinds of Parameters Alice provides several kinds of parameters that can be used in your own methods.

The storyboard In this example, we can write just one method and use parameters to specify: which band member is to perform and which music should be played. solo Parameters: bandMember, music Do together Do in order bandMember move up bandMember move down play music

Demo Ch04Lec2BeetleBand-v2 Concepts illustrated Enter name and select the type of each parameter bandMember is an Object parameter music is a Sound parameter A parameter acts as a placeholder in the instruction Arguments are passed to the parameter in the call to the method

A Number parameter Add a Number parameter to specify the height the bandMember jumps up and down. Note that the call to the method must now include an argument for the height. Traditional Lecture: Demo adding a number parameter for the height of the jump. Active learning: Students add the number parameter and revise the statement to call the method.

Assignment Read Chapter 4-2 Parameters

Lab Chapter 4 Lec 2 Lab