Don Slater Wanda Dann

Slides:



Advertisements
Similar presentations
Alice.
Advertisements

Don Slater Wanda Dann
Implementation with procedural methods. Recall: Step 3 Write statements (code) – a few steps at a time, not the entire program at once! Problem Statement.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Built-in Functions & Arithmetic Expressions.
Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.
Stepwise Refinement -- A procedure calls another procedure
AbstractClassesInterfacesPolymorphism1 Abstract Classes, Interfaces, Polymorphism Barb Ericson Georgia Tech April 2010.
Programming in Alice Chapter 2. Today’s Agenda Designing a Program Writing Methods Executing Instructions Simultaneously Comments Tips for Setting Up.
CS320n –Visual Programming Random Numbers and Random Motion (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Alice in Action with Java
Collaboration Diagrams. Example Building Collaboration Diagrams.
What is Alice? Graphical Programming Environment and Language Learn object oriented programming using 3 dimensional objects and a story telling approach.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Problem Solving with Alice 2 & Friends.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods,
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
Chapter 6: Function. Scope of Variable A scope is a region of the program and broadly speaking there are three places, where variables can be declared:
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Programming Logic Program Design. Objectives Steps in program development Algorithms and Pseudocode Data Activity: Alice program.
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Don Slater Wanda Dann Motion and Rotation Copyright 2012 Wanda Dann, Don Slater All rights reserved.
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.
Decision Structures Chapter 4 Part 2. Chapter 4 Objectives To understand o What relational operators are and how they are used o Boolean logic o Testing.
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
Don Slater Wanda Dann Joint Operations Copyright 2012 Wanda Dann, Don Slater All rights reserved.
Classes and Objects Copyright 2014 Wanda Dann, Don Slater All rights reserved.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Parameters and Event-Handler Methods Alice. Mouse clicks Interactive programs often allow the user to mouse click an object in the display. buttons in.
Class Example - Rationals Rational numbers are represented by the ratio of two integers, a numerator and a denominator, e.g., 2/3. This is opposed to irrational.
Variables & Random Number Generation.  A penguin is playing arctic basketball. The penguin has a basketball and will push the basketball toward.
Writing Our Own Functions Alice. Functionality A function receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Don Slater Wanda Dann
Variables and Inheritance Part 1
Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right window, upper left hand corner start by clicking on Class “MyScene” button.
CS320n – Elements of Visual Programming Sending Parameters to Event Handler Methods (Slides 5-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
Don Slater Wanda Dann Copyright 2012 Wanda Dann, Don Slater All rights reserved.
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.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop More Precise Positioning Camera Marker One-shot methods Saving a world.
Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Functions, Loops, and Parameters.
Repetition Structures Chapter 5 Part The While Instruction  Combines Loop and the condition that is also used in If/else statements  The loop.
Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Variables & Conditions.
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.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Wanda Dann Don Slater Classes and Objects Copyright 2012 Wanda Dann, Don Slater All rights reserved.
Parameters MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project funded.
Joint Motion Copyright 2014 Wanda Dann, Don Slater All rights reserved.
Wanda Dann Don Slater Methods Panel & Object Tree Copyright 2012 Wanda Dann, Don Slater All rights reserved.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
Unit 2 Programming in Alice & Java 1. Day 1: Learning to Program  Objective: Understand the need for step-by-step logic; Basic working of a computer.
Variables and Inheritance Part 1 Alice. Review: Properties A class defines properties for its own kind of object. When an object is created (instantiated),
Functions (Alice In Action, Ch 3) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Beginning Animation. Storyboard An Invitation to Dinner 1.Marlin and Dory (two small fish) are swimming and talking. 2.A shark (Bruce) swims up behind.
1 Quiz Show Programming Terms. 2 Alice - 3D Virtual Programming Vocabulary Quiz Board Chapter 1 Chapter 2a Chapter 2b Chapter 3 Chapter 4 $100 $200 $300.
An Introduction to Programming with Alice Text and Sound in Alice Worlds.
Classes and Objects Copyright 2014 Wanda Dann, Don Slater All rights reserved.
Jonathon Kuo Under the Direction of Dr. Susan Rodger
A Simple Quiz for Alice 3.2:
Chapter 3: Variables, Functions, Math, and Strings
Text and Sound in Alice Worlds
Creating your Function
Alice 3 Using the Alice 3.1 Interactive Development Environment (IDE)
Repetition Control Structures
CS320n –Visual Programming
Making Procedural Methods
A Simple Quiz for Alice 3.2:
Parameters and World-level methods
Using Parameters
Classes and Objects Wanda Dann Don Slater
Classes / Objects / Methods
Presentation transcript:

Don Slater Wanda Dann

How does the penguin “push” the ball? Back to the algorithm Do in order penguin swagger penguin push the ball penguin push Do in order penguin move forward to bump into the ball ball move forward to bump into the pin

 Actually, the penguin could be pushing any target object, so we named the procedure pushObject A second procedure

Implement penguin pushObject Do in order this (penguin) move forward to bump into the ball ball move forward to bump into the pin

Only reference to penguin available in the instance menu We say the ball is out-of-scope (unavailable to be used in the penguin class) Problem: How to move the target (ball) We are working in the Penguin class

 A parameter is used to send information to a procedure when the procedure is called (invoked)  Most built-in Alice statements use parameters ◦ move: direction, distance ◦ turn: direction, angleInRotations

pushObject Parameter: target Do in order penguin move forward (to bump into target) target move forward Algorithm with a parameter

Click add parameter A parameter has a type (what kind of parameter is it?) and a name (a placeholder name)

 Available types are listed in a drop-down menu ◦ Specifies the kind of information the parameter will represent Select Type numeric boolean string of text Gallery Classes

Inheritance Hierarchy  The inheritance hierarchy shows the parent classes of our objects  We see that Penguin is a Flyer  BowlingPin is a Prop  We could use these any of these classes (parents or children) as types for our parameter

Other types But the bowling ball is from the SSphere class, which has to be the type selected

The parameter type Provide a name for the parameter Parameter name

 A parameter declaration consists of  Ssphere target  We say “target is of type SSphere” Parameter declaration

 Select parameter from the instance menu The parameter is now in scope

Create instruction for the parameter

pushObject procedural method

Scene class: myFirstMethod  Drag the pushObject tile into the editor  Select an argument (actual parameter) that will be sent to the parameter (formal parameter). We see that we can only choose ball, as it is the only instance of the Ssphere class we have in our program.