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.
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.
CSC1401 Animation Creating methods/instructions (class-level)
Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.
Parameters and Event-Handler Methods Alice. Mouse input Interactive programs often allow the user to use a mouse to click buttons in a windows-based interface.
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
Fall 2007ACS-1805 Ron McFadyen1 Functions and if-else A function is a collection of statement, similar to a method, but a function is defined to return.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
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.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
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.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
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.
Class-level Methods Chapter 6 part 1. Classes and Objects Classes o In Alice, classes are predefined as 3D models Objects o An object is an instance of.
Today’s Agenda 1.Collect Pre-Lab 5 2.Collect Alice project storyboards 3.Events 4.Dummy Objects 5.Assign pair programming teams and meet upstairs for Lab.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Parameters and Event-Handler Methods Alice. Mouse clicks Interactive programs often allow the user to mouse click an object in the display. buttons in.
Interactive Programming Sec 49 Web Design. Objectives The student will: Understand the difference between movie mode and an interactive program Understand.
Functions Alice.
Variables and Inheritance Part 1
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.
CompSci 4 Chap 5 Sec 2 Oct 18, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper 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.
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.
Review for test! Alice Chapter 1&2 Test is tomorrow! - March 26 th March 25th.
Programming: Simple Control Structures
Programming: Simple Control Structures MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
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.
Lists Alice. Collections In some animations, several objects must perform the same actions Example: A marching band, where the band members are performing.
Repetition: Definite Loops Sec 53 Web Design. Objectives The Student will: Understand loops and why they are used Understand definitive loops Know how.
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.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Alice Final Project Web Design. Alice Final Project You have a choice of two scenarios: 1. A game of some sort. You must devise a score-keeping mechanism.
Alice Project 1 Web Design.
Parameters Section 8-8 Web Design.
Functions Sec 51 Web Design.
Arrays and Array Visualization
Functions Sec 8-11 Web Design.
Parameters Alice.
Lists Alice.
Lists Alice.
Creating an Animation Program
Parameters and World-level methods
Programming: Simple Control Structures
Lists Alice.
Functions Alice.
Lists Alice.
More About Recursion Alice.
Parameters Alice.
Functions Alice.
Class-level Methods and Inheritance
Functions Alice.
Functions Alice.
Class-level Methods and Inheritance Part 2
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 BeetleBand-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 information 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 Argument 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 #1: Beetle Band Duet 1.The Beetle Band example has a method names solo where each member jumps and plays a musical instrument. Recreate the Beetle Band example and write a method named duet, where the solo method is called to have two members of the band jump together and play their musical instruments. 2. This exercise can be done with sound or with lyrics. Parameters must be used to send in the name of the band member and the music to be played or the lyric to be said.