Download presentation
Presentation is loading. Please wait.
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” Race Car Simulator If the car stays on the road, add points to total Else If the car runs off the road, the car explodes If the car crosses the finish line, add bonus points, player wins, display total Else, game over, player loses
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 These will evaluate out to a boolean condition either True or False
6
Compound Conditions Compound Conditions can be used in the If Statements Logical Operators And Or Not And Both conditions Must be true for a true condition Or Either condition can be true for a true condition Not the first condition must be true while the 2nd condition must be false
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.