A very simple Game Program making use of decision statements:Game Program Netbeans Project (zip)
<, >, <=. >=, ==, !=
==
. Instead, use myString1.equals(myString2)
int bigger = (x>y) ? x : y ;
Types of Decision Structures:
... if statement ... if-else statement ... multi-way if-else ... nested if-else ... switch statements ... indentation conventions Code blocks & variable scope Decision Structure Syntax: ... decision logic and flow charts ... condition and body ... boolean value, expression Random numbers |
Building Boolean Expressions: ... relational operator (<, >, <=, >=, ==, !=) ... boolean (logical) operators (!, &&, ||). Examples ... boolean operators precedence (See table) ... truth tables (p. 209) ... De Morgan's Laws (p. 212) String Comparison ... Lexicographic ordering (of Strings) ... compareTo() and .equals operators Other (optional) ... The Conditional Operator bool ? val1 : val2 (p. 182) ... Switch statement (p. 195) |