Lecture 8 Lab 4: It’s up! (Thursdays we post next week’s) – Plan out what you want, bring an implementation strategy diagram – Key Lab: If you’ve been.

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

Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
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.
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?
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 2: Using Methods.
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 3: Billboards, Events, Sounds,
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.
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.
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.
Alice Inheritance and Event Handling. Inheritance Concept Consider this hierarchy; parents describe properties of children Animals Vertebrates MammalsFish.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
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.
Games and Simulations O-O Programming in Java The Walker School
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
As you come in…  DOWNLOADS FOR TODAY:  CarGameTeacherStarter.a2w  Online student textbook.
Lecture 11 Alice Project Deliverable 1: Extension to Midnight! Midterm next class – Midterm review 4-6pm WED Pepper Canyon Hall 106 – Red scantron (1/2.
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.
Lecture 5: Finishing 4.3 and onto 5.1 Preparing for the Midterm: Written Explanations Technology and Society Assignment (5% - 3 in term) – How does the.
Execution Control with If/Else and Boolean Functions
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
Execution Control with If/Else and Boolean Functions Sec 52 Web Design.
Execution Control with If/Else and Boolean Questions Part 1 Alice.
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
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.
The Awesomest Powerpoint Game Ever! (Quest #1) Awesomely Created By Lucy Dowell New Player Returning Player.
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.
Four Fundamental Pieces Instruction Control Structure Function Expression.
Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions.
What we will do today Learn about functions in Alice.
Functions Alice.
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Mathematical Expressions, Conditional Statements, Control Structures
Chapter 6.2 Execution Control with If/Else and Boolean Functions.
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Programming: Putting Together the Pieces Built-in Questions and Expressions Alice.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Variables and Functions Alice. Naming is Important If you get a new pet one of the first things you do is name it Gives you a way to refer to the new.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
Programming: Simple Control Structures
Ready, SET, go! By Melissa Dalis Professor Susan Rodger Duke University July 2011.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
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.
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.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 4-1 Lecture Objectives To understand: –what values can be stored in a Boolean.
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.
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.
* Candy Friday! * Will your class qualify? * Assumptions Activity * T/F Quiz * Fear and Anxiety Differences * Work on your study guide HW/ Coming up: Time.
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.
Alice Development Environment. Which area contains our “program” (set of instructions)? D AB C.
Learn about functions in Alice
Programming: Simple Control Structures
Programming: Simple Control Structures
Let's Race! Typing on the Home Row
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Programming: Simple Control Structures
How Tall Are You? Introducing Functions
Agenda for Unit 5: Control Structures
Presentation transcript:

Lecture 8 Lab 4: It’s up! (Thursdays we post next week’s) – Plan out what you want, bring an implementation strategy diagram – Key Lab: If you’ve been just getting by… You need to look this over before you go to lab! What’s this Alice Project? – Due Sunday before Week 10 – Personal digital contribution to the world Animation or “interactive” animation 3 Deliverables – 1 st due next Monday! – Let’s look on moodle.

What happens when the following instruction is executed? A.Goldfish moves up 1 meter B.Goldfish moves down 1 meter C.Alice will say an error happens

Which kind (type) of value does an expression using a logic operator result in? A.Number B.Boolean C.Object D.Other E.I don’t know

Where is the random number tile found in Alice? (hint, think about what it does) A.In the World’s methods area B.In the World’s functions area C.In the World’s properties area D.In the set of tiles at the bottom of the area where you write your code E.I don’t know

When would this boolean expression evaluate to true? Zeus’s color isHow far Zeus is away from Socrates (distance to) AGreen1 B 3 CBlue1 DAnything not green3

Midterm Practice! Clicker Discussions help you develop and home your ability to analyze and communicate technically You can show us your skills on an exam through a written “explanation” of a multiple choice question Guideline Review: – Make clear your understanding of the question by analyzing it and explaining what it means/is asking for – Use appropriate terminology – Don’t just “re-write” code if you need to explain it, use words that make it clear you understand how it works – Explain why the wrong answers are wrong

REVIEW: Challenge Question: Methods have parameters, functions can too The function “sideLength" is controlled by both the width and height of the pyramid. Why weren't those parameters to the function? A.Beth messed up – they should have been parameters to the function, that was a bad design B.We did pass parameters to the sideLength function – for example these: C.We didn’t need to pass those values because sideLength is a function of the pyramid class D.I don’t know Feedback Paraphrase Justify

Feedback Paraphrase Justify 1.blue, says Ice Cold! 2.red, says Hot! 3.blue, says Ice Cold! AND then says Try again! 4.green, nothing happens A)1B) 2C)3D) 4E) REVIEW

What else can you do with if statements? Make a barn jump if an airplane gets too close – NOTE: You do NOT have to do this this week Let Alice go down the rabbit hole – If Alice’s width is less than then hole’s width Make a plane crash in a simulation – If the plane gets too close to (overlaps with) a ring, a barn, etc. Make it explode and disappear Play “tag” – If one object moves to touch another and it’s “red”, pass on the red state

Write Code Idea: let’s have a three legged race Alice moves forward 0.5 meters when you hit A EskimoGuy moves forward 0.5 meters when you hit E Imagine we have two people playing, trying to move as fast as possible to finish line (right side of screen) – Each is hitting either A or E. – BUT they have to be careful, if they get more than 1 meter apart, then you lose – eg. Disappear from the screen.

What do we need to implement our storyboard? 2 events (to control each character moving forward) – Each calls the goForward method passing as a parameter the Object that should move forward – Any time an object moves forward, we should check to see if they have lost (e.g moved more than 1 meter away from the other character) If so, make both characters disappear If not, don’t do anything (well, wait for another key to be pressed to further move the characters forward).

Developing a Well-Designed Three Legged Race Set up the basic events: for A and E – Move forward (goForward method) – Oh, same thing, just send whoMoves as object 1) Conditional Execution: IF they are too Far Apart – Move both characters underground (game over) – If not, then OK – don’t do anything special (just wait for another event to get triggered) Hint build empty if statements with comments in both parts so you remember what they should do

What we have in moveForward What do we replace “true” with? – What boolean expression do we write to “check” if we should go underground?

Which of these lines would we use to replace “if true” in last slide’s code (find when they are too far apart) C) Both of these would work correctly D) I don’t know Feedback Paraphrase Justify

How many of the following statements are true about our boolean expression It evaluates to true when the game should be over It evaluates to false when the game should be over It evaluates to true when nothing should happen It evaluates to false when nothing should happen It evaluates to some value less than one meter A)1B) 2C)3D) 4E) Feedback Paraphrase Justify

Finishing Up: Developing a Well-Designed Three Legged Race 2) Build Boolean expression to control if statement – True or False: Distance infrontof from one object to other is > 1 meter Wait! We need the “other” object as a parameter Oh, could be negative if behind, use absolute value 3) Make a function: Hide complex expression returning true if “too far in front” into function called – IsTooFarFrom(Object1, Object2) Order of parameters doesn’t matter since we are using absolute value

What if we replaced our if with this? A.It does the exact same thing B.It does the exact opposite (game is over if too close together) C.It almost does the exact same thing, but not quite D.I don’t know Feedback Paraphrase Justify

Picky, Picky Yeah, you would be too if you earned a 90% and you got a B! >= 90% gets an A = 80% gets a B

Additional Practice: Can you figure this out? How do we determine who wins? If one of our players is within.5 meter of stop sign (use distance to) – Then have they should say “I Win!” – And the loser has to do a silly dance It’s not possible that they will both get there at same time (sequentializes keypress detection)

If statements and Booleans: Basically the same in Java!

public class Example { public static void avoidCollision(Object aircraftOne, Object aircarftTwo) { if (aircraftOne.isAbove(aircraft2)) { aircraftOne.move(“up”, 5); aircraftTwo.move(“down”, 5); } else { aircraftTwo.move(“up”, 5); aircraftTwo.move(“down”, 5); } Method Name Parameters for Method If else Function (boolean expression) Method Calls Parameters to move Method

Evaluate my code Last term some Alice projects used if statements in weird (and WRONG) ways – If (true) or if (false) – Empty “body” – Things were “backwards” – Nothing in “then” – just in “else” part

Imagine my project… The synopsis is – A boy and a girl start off 5 meters from a tree. They walk up to a tree, and when they are “close enough” to it (less than 2 meters), the tree leaves change color (turn red)… This is my code

How would you analyze this code? A.Good job Beth! This will make the leaves turn red as described B.The boolean expression is wrong you shouldn’t use < C.The if statement is set up wrong, you also need to check the randomGuy distance to D.Beth got it wrong, this code should not use an if statement Feedback Paraphrase Justify

How many of the following statements are true: Use an if-statement when 1.You have an animation that always does the exact same thing 2.You have an animation whose action can vary based on some circumstance A)0 B) 1C)2 STOP, ASK PARAPHRASE EXAMPLE

What does this code do? World with three “drivable” objects – Forward, Turn by.12 revolutions (1/8 th of the way around) – Midterm Practice: How many events would I need and what would they control? (hint > 4) The scene:

This code lives at the end (bottom) of “forward” event handlers (not turn)

What is this code checking for? (e.g. when will the party method be called) A.To see if any of the objects is near the palmtree B.To see if the penguin is near the palmtree C.To see if all of the objects are near the palmtree STOP, ASK PARAPHRASE EXAMPLE

Do any of these do the same thing? (if all the objects near the tree) STOP, ASK PARAPHRASE EXAMPLE

When does a party happen? A.If any of the objects is near the palmtree B.If all of the objects are near the palmtree C.Something else (e.g. multiple parties…) STOP, ASK PARAPHRASE EXAMPLE

If any object is near the palmtree: Compound Boolean Expression (copied from one line in Alice)

Review both __________ and ______________ either ___________ or ___________ or both Not When trying to read, match up the words above

Aside: Designing if statements that use parameters as objects Wierdism… not real programming See online video Follow this process – 1) “cheat” by picking an actual object from the object tree, and then picking from it’s function set in the left right – 2)Then drag the parameter object you want on top of the object name that you just “cheated” with and it will replace it.