Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Variables & Conditions.

Slides:



Advertisements
Similar presentations
Alice.
Advertisements

Don Slater Wanda Dann
Decision Structures Chapter 4. Chapter 4 Objectives To understand: o What values can be stored in a Boolean variable o What sequence structures are and.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming First Edition.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Built-in Functions & Arithmetic Expressions.
Don Slater Wanda Dann
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Programming: Simple Control Structures Part 1 – Conditional Execution Alice.
Introducing While loops (and random numbers too) Alice.
CS320n –Visual Programming Indefinite Loops (Slides 7-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Alice Programming Step 1:Design Copyright 2011 Wanda Dann, Don Slater, Steve Cooper.
Fall 2009ACS-1805 Ron McFadyen1 Functions A function is a collection of statement, similar to a method, but a function is defined to return a value to.
CS320n –Visual Programming Random Numbers and Random Motion (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
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.
CS320n –Visual Programming Functions Mike Scott (Slides 6-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
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,
Introduction to Alice CS Honors Slides courtesy of Wanda Dann, Ithaca College.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
SOLVING SYSTEMS USING SUBSTITUTION
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Recursion1 Stephen Cooper Wanda Dann Randy Pausch Barb Ericson Jan 2010 Recursion in Alice.
Execution Control with If/Else and Boolean Questions Part 1 Alice.
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.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
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.
Alice Programming Step 1:Design Copyright 2011 Wanda Dann, Don Slater, Steve Cooper.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Four Fundamental Pieces Instruction Control Structure Function Expression.
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.
Functions Alice.
Don Slater Wanda Dann
CS320n –Visual Programming Introduction to Recursion (Slides 8-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Mathematical Expressions, Conditional Statements, Control Structures
Don Slater Wanda Dann Copyright 2012 Wanda Dann, Don Slater All rights reserved.
Programming: Putting Together the Pieces Built-in Questions and Expressions Alice.
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.
Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Functions, Loops, and Parameters.
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.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
Obj: Programming: Simple Control Structures HW: Read section 3 – 2 AC3 D2 Do Now: 1.Log on to Alice. Open the file firstEncounter.a2w located in the folder.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Programming: Simple Control Structures Sec 46 Web Design.
Parameters MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project funded.
CS320n –Visual Programming Problem Solving Case Study (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 4-1 Lecture Objectives To understand: –what values can be stored in a Boolean.
Wanda Dann Don Slater Methods Panel & Object Tree Copyright 2012 Wanda Dann, Don Slater All rights reserved.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
CS320n –Visual Programming Execution Control with If / Else and Boolean Functions (Slides 6-2-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
Variables and Inheritance Part 1 Alice. Review: Properties A class defines properties for its own kind of object. When an object is created (instantiated),
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.
CS320n – Elements of Visual Programming List Search Mike Scott (Slides 9-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Functions Sec 51 Web Design.
Simple Control Structures
Functions Sec 8-11 Web Design.
CS320n –Visual Programming
Design and Implementation
Using Functions in Alice
Programming: Simple Control Structures
Functions Alice.
Relational Expressions
Functions Alice.
Functions Alice.
Functions Alice.
Presentation transcript:

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Variables & Conditions

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Recall: Variable  A variable is an item or value that is likely to change in value.  Variables can belong to:  a specific method (local to that method)  a class (instance, available to all objects of that class)  the world (global, available anywhere in the program)

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Instance variables  In Alice, an object’s properties are instance variables

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Changing a property  A property can be changed, using set

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Condition  The set of of variable values describe the condition of objects in an animation program.  As an animation program is running, each statement is likely to change the value of at least one property of an object.  Therefore, conditions change as a program runs.

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater New variables  Properties are built-in variables, but we can create our own variables to track other values

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Example Problem  A penguin (joe) is watching his son (junior) slide across the ice. A hole in the ice is nearby where junior could fall in. Create an animation where junior slides a random distance toward the water. If junior lands in the water, have him sink under the water and then joe dives in after him.

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Textual Storyboard Do in order junior faces the water junior slides forward a random distance if junior is in the water junior goes down under the surface joe goes in after him Do together joe and junior pop back up to the surface

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Random distance  World function to generate a random number in a range of 0.25 to 3

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Checking a Condition  How do we know whether junior is in the water?

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Is junior in the water?

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Problem Solving  Variables can be used to represent values  Let d be the distance of junior to the water  Let r be the radius of the water

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Creating a variable  A variable has a name and a type

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Set variable value  Call a function to set the value of d

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Use Math to compute radius  Cascading menus for binary operations

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Conditional Execution  Alice provides an If/Else control structure to check a condition

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Boolean Condition  Is junior’s distance to the center of the water less than the radius of the water? Must be either true or false

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater If/Else Statement  Create parameter, targetObj  Pull if/else control into editor

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Relational operations are defined in World’s functions  Alice operators ◦ == means “is equal to” ◦ != means “is not equal to” Operators

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater  Select placeholder operands

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Placeholders  In this example, the operands selected from the cascading menus are just placeholders.  Need to replace with calls to functions to obtain distance of penguin to center of water

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Demo  Implementation of if/else

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Completed Code

Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Text  Chapters 3 & 6  Conditions and If/Else  Chapter 10  Variables