As you come in…  DOWNLOADS FOR TODAY:  CarGameTeacherStarter.a2w  Online student textbook.

Slides:



Advertisements
Similar presentations
As you come in… Sign in (in back) and pick up Badge Name Card – on computer… Log in: Launch/Start Alice Any questions? (of any kind) DOWNLOADS FOR TODAY:
Advertisements

As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)?
As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Log in:  Launch/Start Alice  Any questions?
PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
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.
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.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Any questions? (of any kind)  Put on index.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
2-1 Making Decisions Sample assignment statements PayAmount = Hours * Rate PayAmount = 40*Rate + (Hours – 40)*Rate*1.5.
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
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Chapter 6: (Expressions,) Functions, and If/Else First we had animations – They “ran”/played the same way every time. – Neat, but a bit boring Then we.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Execution Control with If/Else and Boolean Functions
Execution Control with If/Else and Boolean Functions Sec 52 Web Design.
Execution Control with If/Else and Boolean Questions Part 1 Alice.
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.
Branching and Conditions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
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.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
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.
MS3304: Week 6 Conditional statements. Overview The flow of control through a script Boolean Logic Conditional & logical operators Basic decision making.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Flow Control: boolean expressions, “if” selection statements (Alice In Action, Ch 4) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September.
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Mathematical Expressions, Conditional Statements, Control Structures
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
Chapter 6.2 Execution Control with If/Else and Boolean Functions.
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.
JavaScript, Fourth Edition
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
Tutorial on Kangaroo visiting his animal friends - parameters, events Susan Rodger Duke University June 2009.
By: Ms. Abeer Helwa 1. WORD WEB APP 2 Word Web App is a limited version of Word, enabling you to edit, format, and share documents online. Word Web App.
Chapter 3 Decisions Three control structures Algorithms Pseudocode Flowcharts If…then …else Nested if statements Code blocks { } multi statement blocks.
CSI 3125, Preliminaries, page 1 Control Statements.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Improving the Crab Mrs. C. Furman August 19, 2010.
Adding and Eating Worms Mrs. C. Furman August 23, 2010.
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.
Presenter: Carol Liss Timberlane Regional Middle School 6 th and 7 th grade Tech. Educator Co presenters:
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.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Control Structures (Selection & Repetition)
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Tutorial on Bunny visiting his animal friends - parameters, events for Alice 3 Susan Rodger Duke University June 2009 Updated by Yossra Hamid on October.
By Melissa Dalis Professor Susan Rodger Duke University June 2011
Class-Level Variables in Alice
Execution Control with If/Else and Boolean Functions
Simple Control Structures
Repetition Control Structures
Let's Race! Typing on the Home Row
More Selections BIS1523 – Lecture 9.
Lesson 8: Boolean Expressions and "if" Statements
Conditional Statements
2-1 Making Decisions Sample assignment statements
Program Flow Control Selection & repetition
Using Functions in Alice
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
1. Once in the Textbook Select the Chapter you want to read
Decision Statements.
Presentation transcript:

As you come in…  DOWNLOADS FOR TODAY:  CarGameTeacherStarter.a2w  Online student textbook (at bottom of each page below) Module 9.4 SpaceShipGame.a2w

Today’s plan  Functions  Compound boolean expressions and if statements – can solve same problem multiple ways Or – car magnet And – space ship take off  Methods and Parameters

Functions: Calculate a Value and “Return” it.  Hides away complex calculation  When program executes that line/tile: change of control flow!  Jump to code/function that does the calculation  It “returns” the calculated value, which replaces the function call tile  Finally, that line/tile is executed

Examples you know (but can’t see/edit the code for) Object functions  Some calculate numbers  Distance To  Height  Some calculate boolean values  Is within X of Y  Is above

Examples you know (but can’t see/edit the code for) World functions  Some calculate numbers  Random number  Some calculate boolean values  Both a and b  Either a or b or both  a == b  a > b

Compound Boolean Expressions – OR Car Driving Game (watch video 9.2)  Modify: Car should only turn to head towards MAGNETS  One of the 4 magnets  Download from ce21sandiego.org/2013  CarGameTeacherStater.a2w  Let’s create a function to hide away complex boolean expression

Create function: isMagnet Returns: boolean value  Create new World function  Choose returns boolean  Call it isMagnet (we often use “is” for boolean returning functions – Yes or No, true or false)  Drag boolean expression in if to clipboard  Go to isMagnet function definition replace “true” with expression from clipboard  BACK in my first method  Drag complex expression to trash  Replace (default) true with new isMagnet function (look under World, functions – it’s at top)

Compound Boolean Expressions – OR Car Driving Game (watch video 9.2)  In online text – used to show  Two ways you could make this if…  Compound boolean expression

Compound Boolean Expressions – OR Car Driving Game  Two ways if…

Compound Boolean Expressions – OR Car Driving Game  Two ways if… nested if

Compound Boolean Expressions – AND Spaceship takes off  Space ship only takes off if all spheres are blue  Download from online textbook module 9.4  SpaceShipGame.a2w (bottom of page)  Click on World object  Methods – edit Flip Switch  Build this if statement  When true – make dropShip object move up 30 meters

Compound Boolean Expressions – AND Spaceship takes off  Two ways if…

Compound Boolean Expressions – AND Spaceship takes off  Two ways if…

Coming Up…  Week 7: Methods, parameters, and events  Week 8: Lists