Organizing common actions

Slides:



Advertisements
Similar presentations
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.
Advertisements

Monkey See, Monkey Do. Important Turn on Java-like syntax option in Alice, if is not on already.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Repetition Structures
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
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.
1 Quiz Template: Click on the match By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
University of technology Department of Materials Engineering
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
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.
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Getting Started with. EndNote Basic: It allows you to: Collect references from online sources or enter them manually Access your references from any computer.
Copyright © 2015 Curt Hill Models and Textures Making your entity interesting.
Copyright © Curt Hill Turtles The beginning of media computation.
Copyright © Curt Hill First Window Builder Program Easy GUIs in Eclipse.
Introduction to Using the Notebook 10 Software for SMART Board Day 2 LIVINGSTON PARISH PUBLIC SCHOOLS Facilitated by S. Waltman.
Basic & Advanced Reporting in TIMSNT ** Part Three **
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
1 Chapter 4: Creating Simple Queries 4.1 Introduction to the Query Task 4.2 Selecting Columns and Filtering Rows 4.3 Creating New Columns with an Expression.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Nonvisual Arrays by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Speed Tree Let’s Make a Forest Copyright © 2015 – Curt Hill.
Copyright © 2015 Curt Hill Building a Simple Level No UnrealScript but several editors.
Copyright © – Curt Hill Building Windows Applications in wxDev-C++
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
Copyright © Curt Hill Common Dialogs Easily Obtaining File Names in DevC++ Windows Programs.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
Copyright © 2012 Pearson Education, Inc. Chapter 4 Writing Classes : Review Java Software Solutions Foundations of Program Design Seventh Edition John.
Approving a Proxy account. Login to Skylite with your fis account Then mouse down until you get to approve and hit enter.
The for Statement A most versatile loop
Jonathon Kuo Under the Direction of Dr. Susan Rodger
HTML Again GUI Items Originally HTML 4 Copyright © Curt Hill.
Unit 2 Technology Systems
The Second C++ Program Variables, Types, I/O Animation!
Spreadsheet – Microsoft Excel 2010
Getting started in Alice
Chapter 3: Variables, Functions, Math, and Strings
Putting Objects in Motion
GO! with Microsoft Office 2016
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Introduction to Events
Basics for Robotics Programming
Learning to program with Logo
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Predefined Dialog Boxes
Refining our Animations
The C++ IF Statement Part 2 Copyright © Curt Hill
Doing things more than once
Concepts From Alice Switching to Java Copyright © Curt Hill.
A Kind of Binary Tree Usually Stored in an Array
After editing the answers you will need to copy and paste this group of answers and background panels to whichever Panel Board Slide you choose. To learn.
Arithmetic Expressions
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Chapter 2: Programming in Alice
Arrays
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events
Using Lists and Functions to Create Dialogue
How to submit preferences in TAMS as a Faculty member
Using screens and adding two numbers - addda.cbl
Professor Susan Rodger
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
First Window Builder Program
Selection Statements Chapter 3.
Professor Susan Rodger
An Introduction to Designing and Executing Workflows with Taverna
The beginning of media computation Followed by a demo
Presentation transcript:

Organizing common actions Methods Organizing common actions Copyright © 2005-2017 Curt Hill

A Problem The simple objects are just moved Those which have moving parts should move them The fish should move its tail back and forth, open and close its mouth Doing it once is not problem More than once gets real tedious We do not want to use the move method but the swim method should take this into account Copyright © 2005-2017 Curt Hill

The Solution A method is a group of instructions that are bundled together They can be created and then executed like any of the predefined methods that come with the actors The goal is now to create a swim method that moves the fish forward and wags the tail as it is moving Better yet it is easy to do Copyright © 2005-2017 Curt Hill

Methods Three steps: Create a new method Uses the button in Details Pane Put the new statements in the method Call the method from elsewhere Copyright © 2005-2017 Curt Hill

Creation Next we look at the creation in three screens In the first we have turtle selected The mouse is over the Create New Method Button Notice the hint showing Second we name the method In this case swim Third we now have two method tabs The leftmost is the first method which starts when the world starts The rightmost is the new empty method Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Put New Statements in Method Same procedure as before Drag statements in In this case one move forward One set of turns for each foot A Do Together and four Do In Orders Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Calling the New Method User-defined methods are just like predefined methods Using a predefined method is just like using one you created Mostly Observe the following screen shot of the turtle swim Notice: New one is above the button It also has an edit button It is used in the Method Edit pane Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Differences Slightly different on the left Somewhat different on the right Most methods have a parameter A parameter modifies how the action occurs The move method has two obvious parameters Direction Distance A move cannot be given without these Copyright © 2005-2017 Curt Hill

Parameters A parameter is a value that is passed to the method when it is executed Some methods have no parameters Many methods have required parameters and optional parameters A required parameter must be given An optional parameter may be given otherwise there is a good default value Copyright © 2005-2017 Curt Hill

Parameter for swim? Swim does a move but does not allow the move distance to be set Let us make the distance a parameter This will be plugged into the move directly How is this done? Observe the swim method Create New Parameter button Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Create New Parameter The Create New Parameter button brings up a dialog box In this box we choose a type and a name The name is how the parameter is referenced inside the method The type is the kind of data: Number, boolean, object, string Here is a shot of this: Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Using the Parameter Anywhere a constant number may be used a numeric parameter may now be used When a numeric is specified in a drop down list there are three options besides a constant Other – you specify on calculator Expression – a parameter or variable Math – a calculation using parameter Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Math Instead of a numeric we may also use a calculation This gets somewhat tedious to specify but we can make it work To get an expression like: time / 4 we need to first specify the expression time then specify math Here is the second half Copyright © 2005-2017 Curt Hill

Copyright © 2005-2017 Curt Hill

Math Revisited The drag and drop approach gets to be a problem in math expressions that are somewhat complicated First step is set the item that is to left of operator Second step is to specify a math and then choose the operator and the item to right We will see this in next exercise Copyright © 2005-2017 Curt Hill

One More Thought We typically use methods in two ways Capture a common action so that we can use it again and again A swim or walk method Use it to organize our movie Each scene becomes a method The method is only called once, but it organizes our movie Copyright © 2005-2017 Curt Hill

Method Exercise In this exercise use a method to make any type of motion more natural Call the method several times Use parameters Copyright © 2005-2017 Curt Hill