html5-img
1 / 7

REVIEW FOR LESSON 8

REVIEW FOR LESSON 8. Boolean Logic. 1. What does the following write to the output window? var dude:Boolean = false; var score:Number = 10; if (dude == true) { trace(score+20); } else { trace(score-10); }. false 30 10 0.

cerise
Download Presentation

REVIEW FOR LESSON 8

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. REVIEW FOR LESSON 8 Boolean Logic

  2. 1. What does the following write to the output window?vardude:Boolean = false;varscore:Number = 10; if (dude == true) { trace(score+20); } else { trace(score-10);} • false • 30 • 10 • 0

  3. 2. What does the following write to the output window?varscore:Number = 10; if (score < 10) { trace(“Hello Bobby!”); } else if (score > 10) { trace(“Hello Danielle!”); } else { trace(“Hello Jill!”); } • 10 • Hello Bobby! • Hello Danielle! • Hello Jill!

  4. 3. What does the following write to the output window? var p1Score:Number = 25; var p2Score:Number = 30;varmaxScore:Number = 50;if (p1Score + p2Score >= maxScore){maxScore = p1Score + p2Score; trace(maxScore);}else{ trace("You didn’t win!! My score of " + maxScore + " is still the best!");} • Syntax Error • 50 • 55 • You didn’t win!! My score of 50 is still the best!

  5. 4. What does the following write to the output window? var p1Score:Number = 25; var p2Score:Number = 30;varmyTurn:Boolean = true;if (p1Score >= p2Score && myTurn == false){ trace(“I’m winning, but it’s your turn.”);}else if (p1Score <= p2Score && myTurn == false){ trace(“I’m losing, and it’s your turn! Aah!”);}else if (p1Score == p2Score && myTurn == false){ trace(“We’re tied, but it’s your turn.”);}else if (p1Score == p2Score && myTurn == true){ trace(“We’re tied, but it’s my turn.”);}else if (p1Score >= p2Score && myTurn == true){ trace(“I’m winning, and it’s my turn.”);}else if (p1Score <= p2Score && myTurn == true){ trace(“I’m losing, but it’s my turn! Ha!”);} • I’m winning, but it’s your turn. • I’m losing, but it’s my turn! Ha! • I’m winning, and it’s my turn. • Nothing

  6. 5. What does the following write to the output window? varhasLicense:Boolean = false;varhasCar:Boolean = true;varmyAge:Number = 16;varsheWantsToGo:Boolean = true;if (hasLicense == true && sheWantsToGo == true){ trace("Let’s go!");}if (myAge >=16 && hasCar == true){ trace("I’ll go.");}if (hasLicense == false && hasCar == false || sheWantsToGo == true){ trace("I’ll find a way to go…");}if (hasCar == true && sheWantsToGo == true && hasLicense == false){ trace("We’re going anyway")}else { trace("I’m a loner… but that’s okay.");} • I’ll go. • I’ll find a way to go… • We’re going anyway • I’ll go. I’ll find a way to go… We’re going anyway

  7. 6. If statements can use shorthand comparisons to check whether a statement is true, for example:if(HaveFriends == true) is the same thing as if(HaveFriends)Placing the ‘== true’ is unnecessary. It also works for false statements, for example:if(HaveFriends != true) is the same thing as if(!HaveFriends) Knowing this, what does the following write to the output window? varallMyFriendsDoIt:Boolean = true;varitsJustOne:Boolean =true;varnobodyWillKnow:Boolean = true;varisTheRightThingToDo:Boolean = false;if (allMyFriendsDoIt && itsJustOne && nobodyWillKnow && isTheRightThingToDo){ trace("I'll do that.");}else{ trace("I will not do something that is not the right thing.");} A. Nothing B. I’ll do that. C. I will not do something that is not the right thing. D. I am so confused right now. I need help.

More Related