1 / 13

Decision Statements

Decision Statements. Control Stuctures. Sequential Processing Do In Order D o Together If / Else Statements  Decisions Repetition  Looping. If / Else Statements. Make a decision based on the value of a condition (at Runtime) If a condition is True Do “A”

lana
Download Presentation

Decision Statements

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. Decision Statements

  2. Control Stuctures • Sequential Processing • Do In Order • Do Together • If / Else Statements  Decisions • Repetition  Looping

  3. If / Else Statements • Make a decision based on the value of a condition (at Runtime) • If a condition is True • Do “A” • Else (meaning the condition is false) • Do Nothing • Do “B”

  4. Boolean Functions • Functions returning a Boolean Value are often used in Decision Statements • If the function returns a True Value • Do “A” • If the function returns a False Value • Do Nothing • Do “B”

  5. Relational Operators • Used in Expressions for If Statements == Equal To != Not Equal To < Less Than > Greater Than <= Less Than or Equal To >= Greater Than or Equal To

  6. Compound Conditions • Compound Conditions can be used in the If Statements • Logical Operators • And • Or • Not

  7. Example • Problem 6-2, #11 Write a vocabulary builder to help someone learn the Spanish word for Cat (gato). 3 Spanish words are displayed, if the user clicks on the correct word have the cat say “Si, Si”, if the user clicks on one of the other words have the cat shake it’s head back and forth

  8. World Creation

  9. Boolean Function • Write a function (isGato) that returns true if the word “gato” is clicked and returns false otherwise. • Parameter – • objectClicked – the 3D word clicked by the user

  10. isGato Function

  11. checkAnswer Method • Event Handling Method Compound Condition

  12. Link Method to Event

  13. Homework • Chapter 6-2 • Problems 13, 14, & 16

More Related