Lecture 12 or President’s Day Holiday Chapter 7.2 While Loops – Finish up our race of the penguins.

Slides:



Advertisements
Similar presentations
Chapter 12 Sorting and searching. This chapter discusses n Two fundamental list operations. u Sorting u Searching n Sorted lists. n Selection/bubble sort.
Advertisements

By: Malikova Farida.. Hello! My name is Malikova Farida. I live in Pavlodar in Kazakhstan. I go to Zhas daryn school in 7 class. I am 12.
August 15 Physics. Homework quiz A race horse runs with an average velocity of 12 m/s for 35 seconds. What is its displacement? If it crosses the finish.
The Race is On! Putting Words in Alphabetical Order.
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:
1 Computational Geometry Chapter Range queries How do you efficiently find points that are inside of a rectangle? –Orthogonal range query ([x 1,

Linking Verb? Action Verb or. Question 1 Define the term: action verb.
P.H.H.S NJROTC JV Ex Teams!. U narmed E xhibition Commonly Known as “Dancing in Formation”
Unless you work hard, you ………… a diploma. won’t get.
Today’s Bellringer 11/01/13 Rewrite these sentences to correctly punctuate the dialogue. When you are finished, take out your WW4 list and study it. How.
What is he doing? He is eating..
FUTURE TENSES  WILL  BE GOING TO  PR. CONTINUOUS  FUTURE CONTINUOUS  FUTURE PERFECT © Beni Suárez Prado.
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.
Student : Zaimez Rodriguez, Adrian Group: 103 Group: 103 “English” Teacher: Sergio Valdivia.
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?
Holiday Hearts
Programming in the Arts Deirdre Russell-Bowie Music, Dance, Drama and Visual Arts.
When the Crab was Dreaming The story by Menson Li Class:4A.
SPIN
My Personal Budget Vocabulary
GO PLAY WITH MICKEY. COOK PAINT SURF RUN SLEEP WALK DRIVE SWIM Mickey is painting.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
CHAPTER 2 ANALYSIS OF ALGORITHMS Part 2. 2 Running time of Basic operations Basic operations do not depend on the size of input, their running time is.
CS2420: Lecture 8 Vladimir Kulyukin Computer Science Department Utah State University.
1 Session-13 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-5 due date extended to March 7 Test-1 is on March 9 th ; Demo-5 due date extended to.
How to thread the Sewing Machine. Winding the Bobbin Place your thread on the spool pin Pull thread around knob on opposite end of the machine Thread.
VAVLPVCTYMAUS PSABLADDERZSB EBSANTESHTICL RLDUDSKTTVSRA EDEARCENEAUOD CRFNORSASINTD TPEUUOCPTDATP UNRTMTRBEEXME MIEUSUULSNSNN USNMEMNISAIIT AESXSVPENNISI.
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.
QPLNHTURBIOTS CADAIASOINCOS OSTPOSTLGVAGT AJRLFKLEROUEA CLARITYSOLSTB HTEAMVSRUVAHI INTERACTPELEL NAPKSOCIALIRI GSOCIOGRAMTST CONFORMITYYTY 14 WORDS ANSWERS.
The Generator. Electricity Generator Energy: The ability to do work Two Examples: Mechanical Energy: Energy that comes from the motion of an object Electrical.
Chapter 61 More about Loop Do ….. Loop Write Down “Do” and “Loop”
Getting Started! Lego Mindstorms Program NXT 2.0.
Describe Them! Pass the Ball Game Speak loudly and clearly!
Programming a light sensor to follow a black line.
Saving water at home WATER IS LIFE. KITCHEN  Problem 1: The tap is running when we don’t use it. You’re washing the dishes under a running tap.  Solution:
Booked for 12th July 2016 Packed lunch on first day. Tuesday – Newlands (start activities straight away!) Friday – am activities – home for 4:00pm Expect.
Textbook Problem Java – An Introduction to Problem Solving & Programming, Walter Savitch, pp.219, Problem 08.
Canada Treasure Hunt! Mexico. You come home with your best friend Martina and hear a loud bang in the attic. You really want to go up there because your.
Speak and write in English
Part 10 Carlos So where are you working this summer, Carlos? Oh, I’m working as a tutor in a learning center for kids. Interesting. What kinds of.
My most favourite hobby is teaching my Dog “Hugo” tricks. When I grow up I want to become a veterinarian or a dog trainer. I spend my whole day with hugo.
BY MEGAN Day of the Dead. Where is it Celebrated? It is usually celebrated in Mexico. Mostly in the Spanish speaking country’s.
The Lion and the Hare Class: ___ Teacher: ___. The lion is big and strong. The lion is hungry, too!
Science Chapter Choice1Choice 2Choice 3Choice
How to distinguish different verb tenses
Point-Slope Form of an Equation Notes Over 5.5 Use the point-slope form of a line to write an equation of the line that passes through the given points.
1. You are walking down the street when a dog comes running from the other direction. As the dog runs towards you, you have to jump over the dog,
Gemma Jones. I am going to look at the positive and negative effects between manual hand washing dishes and dishwashing machines through;  Cost  Energy.
Unit #2 – Favourable & Unfavourable Travel Balances
THEY ARE DANCE. THEY ARE DANCING. THEY ARE DANCEING. NEXT.
WHAT DOES KAREN DO EVERY DAY?.
CHAPTER 8 SECTION 6 NATURAL LOGARITHMS Algebra 2 Notes ~ May 6, 2009.
What time do you have to wake up on the week? I wake up at 6: 00 a.m every day.
You are going on holiday to Egypt. You have £200 spending money to take.
I finished washing the dishes, put on my coat, and walked onto the porch. I looked up to the sky and said to myself, “There sure is a beautiful Earth out.
7.2 Batch Processing All data are collected into groups and sorted into sequence before being processed together. Computer Studies Today Chapter.
Once upon a time there was a speedy Hare who always bragged about how fast he could run. “I’m better than everyone in this forest.”
Washing the Car The air is cool and newly bitten by the coming autumn;
I Like to Run.
The Tortoise and the Hare
مديريت موثر جلسات Running a Meeting that Works
The Continuous Tenses.
St. Mark’s Dining Hall Dining Hall Rules.
Verbs in the past, present and future tense
Time Worded Problems.
Penguins The TV is on. We are best friends! On off On In out Inside
Glide slide 2 slide 4 walk walk run run run run.
Common pattern/tool: Accumulator loops
Certification Testing
Presentation transcript:

Lecture 12 or President’s Day Holiday Chapter 7.2 While Loops – Finish up our race of the penguins

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)