Creating Functions Pepper. Homework Asking the user: –Drag variable to create a set statement –Drag a world function NumberDialog or StringDialog over.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Mike Scott University of Texas at Austin
Getting Started With Alice: The Basics By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Alice Learning to program: Part Four Creating Sounds, Making Billboards, Fun with 3-D Text, New Events, and Rotating Objects by Ruthie Tucker and Jenna.
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 2: Using Methods.
Class-level Methods Chapter 6. Class-level Method Is specific to a class of objects We can give a class new abilities/methods Only involves this one class.
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.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Functions and Visual Effects Chapter 6 Part 3. Built-in Functions We have been using built-in functions so far 2.
Session 5 of 10 Review + Multiple Sprites
Alice Variables Pepper. Set to Java look Edit / preferences restart.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
2.4 Solving Equations with Variables on Both Sides
The Four Kinds of Sentences
Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Rodger Duke University, July 2008.
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
Creating Functions Deborah Nelson Duke University Professor Susan Rodger July 22, 2008.
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech June 2011.
1 Quiz Template: Click on the match By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Making a Timer in Alice.
Introduction to Python
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Submitting your work online This is a two stage process 1.First you need to add your submission to Moodle, this is usually done by uploading one or more.
Section 3 Calculations National 4/5 Scratch Course.
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.
Sharepoint Getting started. Please log on to the Adult and Family Education website: adulted.d11.org Then go to AFE Teaching Staff and click on Valerie.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
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.
Tutorial on Kangaroo visiting his animal friends - parameters, events.
Scratch Programming Lesson 4 Question asking and answering.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
INTRODUCTION TO DATABASE USING MICROSOFT ACCESS 2013 Part 5.2 November 16, 2014.
1 Quiz Template: Using the ‘ask user’ functions By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
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.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Solving Systems of Equations By Elimination. Warm – up!! *As you walk in, please pick up your calculator!!* Use substitution to solve the following systems.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Using Placeholders to Simplify your Methods: Learning Methods, Part 2 By Deborah Nelson Duke University Professor Susan Rodger June 16, 2008.
If you don’t have Google Earth downloaded already, you can go to to get it.
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.
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech.
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
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.
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.
Class-Level Variables in Alice
Madlib-Input, Strings, and Lists in Scratch
Spanish Mad libs with Scratch
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Videos For All Classrooms
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Review.
Organizing common actions
Programming using Alice 3
Creating Functions Pepper.
Alice Variables Pepper.
TELL ME WHEN YOU FINISH SO WE CAN SAVE
Basic Lessons 5 & 6 Mr. Kalmes.
Basic Mr. Husch.
Presentation transcript:

Creating Functions Pepper

Homework Asking the user: –Drag variable to create a set statement –Drag a world function NumberDialog or StringDialog over the value Speaking a number –Drag a character’s say method to create a say statement –Drag the world’s to string function –Drag the variable into the world’s to string function

Practice now Create a movie with one character Ask name Say name If time – –Ask number –Say number

Ask name movie solution It would be great to have one balloon with “oh, my name is xxxx” Use world string function a + b Do that now – –Click world, then function –Drag a+b over “oh my name is “ string –Select bunnyName variable

Ask Name solution 2

Functions we have used World User question for number World to String Bunny Distance to

Why a function? Want something done – but you want an answer back Example: –Calculate an order price –Give the user a screen of questions and pass back whether they hit ok or cancel –find out whether a move is valid (must give some info) –Find out what should happen when the user hits a guardrail

Create your own function Purpose – tell me how far will be close to the horse –using the rule: give me 90% of the way to the horse

How? Add a horse to your world Click the bunny Click function and then new function, named getCloseDistance Return a number Click new variable closeDist Drag down variable to make a set statement Drag distance to over the set value and then choose horse Drag down the variable again to make another set statement and choose expression / variable /math *.90 Drag the variable into the return statement

getCloseDistance Now, use this function in your movie:

New function questions Which command used the function? Why did you need a variable in this case to put the function into? Can you use this function without putting it into a variable?

Function vs method How is a function different than a method? How is a function the same as a method?

Function with Parm I want the main program to control how close – send the % How? –Create new parm in function –Use parm instead of.90 –Change main program to send.90 –Call with.50 on first line and then with.90 on last line

Solution

Add parm of which object Control which object it moves to in the main program

Solution

Make your own function 2 to have your character ask the user their first name and last name and return the full name. (use a+b world function to put together full name) Create the function: –Click on character –Click on function –Click create new function returning a string –In the function: Click new variable for first name Click new variable for last name Ask user for first name Ask user for last name Return first + last (dragging over to what)

New function solution

Property Values Use – drag to set color Would be great for characters to know their names Ask and put answer into self Change your program to save the name into self Say their name at the end of the program

Homework Have finished reading chapter 1, 2 & 3 Each person should add 2 methods to any one character. 1) a whoAmI function that will ask the user for his first name and last name and return the full name. 2) a sayHello method that accepts a name parameter and will say "My name is " and the name parameter and "I have a movie for you." When the methods have been added, please upload your character to the discussion board. Then, one person can create a movie with these characters. Create a variable for each character's name. Then it should ask the user to name the characters (meaning set variable to the whoAmI function). Then, it should call the sayHello method on each character, passing in their name. Only one person needs to upload. Please name the world file with both people's names. ex: kris_pepper_and_mary_smith.a2w