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.

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.
Chapter 7.2 While – Conditional Loops. What is the BEST description of how many times a while loop executes? A.Some fixed number of times that the programmer.
Lecture 12 or President’s Day Holiday Chapter 7.2 While Loops – Finish up our race of the penguins.
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?
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.
Events Chapter 7. Interactive Real world is interactive User determines order of actions instead of programmer.
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.
Repetition Structures
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
Fall 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
Fall 2009ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
While: Indefinite Loops Sec 8-14 Web Design. Objectives The student will: Understand what an Indefinite Loop is Understand how create an indefinite loop.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
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.
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.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Alice Variables Pepper. Set to Java look Edit / preferences restart.
Loops – While, Do, For Repetition Statements Introduction to Arrays
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
General Computer Science for Engineers CISC 106 Lecture 13 Roger Craig Computer and Information Sciences 3/13/2009.
CSE 115 / 503 Introduction to Computer Science For Majors I Carl Alphonce 219 Bell Hall.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Chapter 7: Repetition 7.1 Definite loops (counted) 7.2 Conditional loops (indefinite)
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley This week: Whew!!! The last homework was tough! The homework for this week.
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.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
This will let you see the game you are going to play on the inside. It will help you see what all goes into creating instance to that goes into setting.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
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.
CompSci 4 Chap 7 Sec 2 Apr 7, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
Chapter 4: Classes, Objects, and Parameters 4.1 World-Level methods.
Q and A for Chapter 7 Students of CS104, and me, your benevolent professor, Victor T. Norman, PhD.
Mathematical Expressions, Conditional Statements, Control Structures
Algorithms Writing instructions in the order they should execute.
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.
CONTROL FLOW The order in which blocks are executed is called the “control flow” of the script So far all our scripts have just executed blocks in the.
Repetition Structures Chapter 5 Part The While Instruction  Combines Loop and the condition that is also used in If/else statements  The loop.
Programming: Putting Together the Pieces Built-in Functions and Expressions Alice.
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
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.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
WE AND THE GAME WE AND THE GAME All of us, boys and girls, we have the right to play, to rest and have some free time. At school we like to play in the.
Lecture Wed Week 7 Midterm grades on gradesource – Graded out of 26 (free point) – Question 1 confusing – everyone gets full points – Solutions posted.
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.
FOP: While Loops.
CprE 185: Intro to Problem Solving (using C)
CMSC201 Computer Science I for Majors Lecture 13 – Midterm Review
Chapter 3: Decisions and Loops
While: Indefinite Loops
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
CMSC201 Computer Science I for Majors Lecture 13 – Midterm Review
Design and Implementation
CprE 185: Intro to Problem Solving (using C)
CMSC201 Computer Science I for Majors Final Exam Information
CMSC201 Computer Science I for Majors Lecture 12 – Midterm Review
CprE 185: Intro to Problem Solving (using C)
Presentation transcript:

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 page) at bookstore (get 2) and pencil – Closed book, no cheat sheet – Sample midterm: PeerWise and posted “explain” – DOES NOT COVER Chapter 7 – Seated by random seat number as you walk in the door Get assignment in lobby If you have an AFA for midterm, please use course communication form: put “AFA MIDTERM” in comment area

Deliverable 2: Due beginning of Lab next week! Fix up storyboards (expand, change, etc. as needed) Implementation Strategy Diagram (what methods call what other methods?) Background Scenes created with objects in them Methods "created" with comments inside about what goes on there – The actual code you can fill in during lab

How To Study For Exams in CSE3 (also redo homeworks and labs (or at least review) ) Re-Take Clicker questions (not just “review” them) – Use PeerWise, read and re-phrase for yourself an explanation Practice writing down your explanation, use the sample midterm as a guide Midterm Review with Sarah – Wed, 4-5:50pm – Pepper Canyon Hall, 106 – Bring specific questions you want her to review… E.g., their name on PeerWise… You will need a red half-page scantron -- bookstore

What is the BEST description of how many times a while loop executes? A.Some fixed number of times that the programmer can determine before the code runs B.Some fixed number of times that can be calculated with a function C.Some variable number of times that is determined by the distance of one object to another D.Some variable number of times that programmer cannot determine before the code runs

What loop header would keep a shark swimming after a goldfish until he was within 0.5 meters behind the goldfish?

We change the while loop Boolean expression controlling the chase to this What does it do (when will the loop iterate)? A.Chase until the goldfish turns blue B.Chase until the goldfish turns a color other than blue C.Chase until the shark gets close

Bunny Square Dance We want to direct the bunny to hop in a square pattern. The “length” of each side of his square should be 5 hops. Here’s the structure of our code, what numbers would you put in for each missing number?

Outer Loop countInner Loop countTurn parameter A45.25 B451 C54 D541 Goal: Hop in a square, 5 hops on each side

What does this code do? A.Makes the guy move “up close” to the girl B.Makes the guy move toward the girl, but not all the way toward her C.Makes the guy move toward the girl and then go on past her D.I don’t know

The primary benefit of using a function to control the number of times a loop runs is… A.The function can be used to make the loop run a fixed number of times B.The state of the world can be used to calculate how many times a loop should run C.The function can be used to allow the loop to run forever. D.I don’t know STOP, ASK PARAPHRASE EXAMPLE

Games: Infinite loops and events Set up: – A bunny, a cat, and a hawk all “move” in “squares” 2.5 meters on a side moving forward.5 meters at a time – An anvil hovers above their head Game: – When I click on an animal, the anvil drops down and “smooshes” them (they go invisible) then the anvil returns to it’s place so I can click again – An infinite loop is used to keep all the animals continuing to move in their square patterns The question I will ask you is about the nested loops controlling this game (how many times does each run)

In the nested loops that control this code how many times should the loops run? Outer LoopInner Loop A55 B5Infinite C 5 D

After I click on an object (say the bunny) and call goBye that object stops moving around A.True B.False C.I don’t know

Section 7.2 While (Indeterminate) Loops While loops execute some number of times that we cannot determine before the code runs “Programming allows a person to think more logically, thinking in order and debugging allows the user to gain valuable problem solving skills. Aspiring to go to law school, thinking logically is extremely important and I think this has helped.”

If I have a chase that should keep going on until the goldfish turns blue (pretend he turns blue after fleeing for a certain amount of time) what condition should we use to control the while loop in the chase method? D) A and C E) B and C

Hint to getting while loops right Humans naturally think “until” – I’ll keep spending until I run out of money (balance <= 0) – I’ll keep dancing until I fall asleep Computers use “while” loops – the opposite – I’ll keep spending while I still have money (balance > 0) – I’ll keep dancing while I am not asleep – While I have a dirty dish, I’ll keep washing dishes

Let’s have a race… A – Wind up penguin (he just goes) While loop with “walk and spin” inside it – Jet-pack penguin2 (controlled by <- event) Moves forward.5 meters Race to a stop sign (within 2 meters) Whenever someone gets within 2 meters – Stop looping (going)

When should we keep going? e.g. while loop expression true (P1: wind up, P2: jet pack) CasesABCD P1, P2 outsideTTTT P1 inside, P2 outsideTTTF P2 inside, P1 outsideTTFF P1, P2 insideTFFF

Which while loop header (tile) would you use to control the “going”?

This would STOP the game (evaluate to false) when A.Both penguins must be close to the stop sign B.Either penguin is close to the stop sign C.Neither penguin is close to the stop sign D.I don’t know What does the other one do?

CasesE1E2Evaluates To (keep playing while true) P1, P2 outsideTT P1 inside, P2 outside FT P2 inside, P1 outside TF P1, P2 insideFF Truth Table for OR logical operator

CasesE1E2Evaluates To (keep playing while true) P1, P2 outsideTT P1 inside, P2 outside FT P2 inside, P1 outside TF P1, P2 insideFF Truth Table for AND logical operator

Let’s look at the code I wrote:

The jet pack penguin (P2) can move forward on a <- event when A.Neither penguin is close to the stop sign B.The windup penguin is close, but the jet pack penguin isn’t C.The jet pack penguin is close, but the windup penguin isn’t D.Any time (any possible situation of TT, TF, FT, FF)

Both penguins stop moving when someone “close” To fix this we’d need to create how many of the following? 1.Method for <- event handler 2.Method to be called by the windUpAndGo method 3.If statement in <- event handler 4.If statement in penguin move method 5.If statement in windUpAndGo method

Which if statement would you want and why? Allow to move when… C) Both A and B D) Neither A nor B E) I don’t know

Let’s Build This…

2 meters from the stop sign? That seems far! (3-D object representation trickiness) Stop Sign center: in middle SIGN Penguin center: in middle of FEET I want to control stopping by distance of penguin center from BASE of stop sign! Use math – again SQRT( c*c – b*b) SQRT (penguin.distanceTo(stopSign) * penguin.distanceTo(stopSign) – stopSign.height * stopSign.height)