CS111: Operators - Boolean Operators
Using && and || operators for compound conditions
Operators: Boolean Operators
Objective
Students must use boolean operators to create compound conditions for complex game logic.
Evidence
Boolean operators in game components:
- Ghost.js - AND operator (&&) for multiple conditions
-
DeathBarrier.js - AND and OR operators (&&, ) - Multiple classes - Compound conditionals
Implementation Details
- AND operator (&&) requires all conditions true
-
OR operator ( ) requires at least one true - NOT operator (!) negates a condition
- Short-circuit evaluation for efficiency
- Combining operators for complex logic
Key Concepts
- Logical AND (&&)
-
Logical OR ( ) - Logical NOT (!)
- De Morgan’s Laws for simplifying expressions
- Short-circuit evaluation
- Operator precedence with boolean operators