Static Constants and Classes . . . . . . . . . . . . . . . 150 Chapter 6 Review and Assessment . . . 161 Chapter 7 Drawing . . . . . . . . .164 Section 7.1 Java Graphics Components . . . . . . . . . . . . . . . . 166 JavaFX Application Class . . . . . . . . . . . . . . . . . . 166 Scene Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Section 7.2 Text and Color . . . . . . . . 174 Text Component . . . . . . . . . . . . . . . . . . . . . . . . . 174 Color Component . . . . . . . . . . . . . . . . . . . . . . . . 178 Section 7.3 JavaFX Shapes . . . . . . . .185 Two-Dimensional Shapes. . . . . . . . . . . . . . . . . . 185 Java Path. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Chapter 7 Review and Assessment . . .199 Chapter 8 Selection. . . . . . . . .202 Section 8.1 Conditions . . . . . . . . . . .204 Operators and Conditions . . . . . . . . . . . . . . . . . 204 Operator Precedence. . . . . . . . . . . . . . . . . . . . . . 208 Section 8.2 Selection Statements . . . 211 Selection Statement Construction . . . . . . . . . . 211 Switch Statement . . . . . . . . . . . . . . . . . . . . . . . . . 215 Scope and Visibility of Variables . . . . . . . . . . . . 219 Common Errors with Conditionals . . . . . . . . . 219 Section 8.3 Helpful Conditions . . . . .221 Nested Selection Statements . . . . . . . . . . . . . . . 221 De Morgan’s Laws . . . . . . . . . . . . . . . . . . . . . . . . 223 Truth Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 Section 8.4 Comparing Objects . . . . .228 Overview of Comparisons . . . . . . . . . . . . . . . . . 228 Equals Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 EqualsIgnoreCase Method. . . . . . . . . . . . . . . . . 229 Rock-Paper-Scissors . . . . . . . . . . . . . . . . . . . . . . 230 Chapter 8 Review and Assessment . . .235 Chapter 9 Repetition. . . . . . . .238 Section 9.1 Java Loops. . . . . . . . . . .240 Overview of Loops. . . . . . . . . . . . . . . . . . . . . . . . 240 For Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 While Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Do/While Loop . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Section 9.2 Applying Loops. . . . . . . . 253 Reading from External Files. . . . . . . . . . . . . . . . 253 Troubleshooting Loops. . . . . . . . . . . . . . . . . . . . 259 Chapter 9 Review and Assessment . . .265 Chapter 10 String Processing . . .268 Section 10.1 Creating Strings . . . . . . 270 Defining String Literals. . . . . . . . . . . . . . . . . . . . 270 String Input Review. . . . . . . . . . . . . . . . . . . . . . . 271 Building Strings Using Concatenation Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Section 10.2 String Methods. . . . . . . 276 Length of a String. . . . . . . . . . . . . . . . . . . . . . . . . 276 String Indexes. . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Extracting Characters from a String. . . . . . . . . 277 Changing Case . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 Searching for Characters . . . . . . . . . . . . . . . . . . 281 Replacing Characters. . . . . . . . . . . . . . . . . . . . . . 284 Section 10.3 Processing Strings Character by Character . . . . . . . . .289 Extracting Characters . . . . . . . . . . . . . . . . . . . . . 289 Wrapper Classes. . . . . . . . . . . . . . . . . . . . . . . . . . 294 Chapter 10 Review and Assessment . . .299 Chapter 11 Managing Input and Output . . . . . . . . . . . .302 Section 11.1 Handling Exceptions . . .304 Overview of Exceptions . . . . . . . . . . . . . . . . . . . 304 Error-Catching . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 Section 11.2 Data Validation and Output . . . . . . . . . . . . . . . . . 310 Input Validation . . . . . . . . . . . . . . . . . . . . . . . . . . 310 Output to a File . . . . . . . . . . . . . . . . . . . . . . . . . . 314 Chapter 11 Review and Assessment . . . 321 Chapter 12 Custom Classes and Methods . . . . . . . . . . . . .324 Section 12.1 Creating a Class . . . . . . 326 Class and Data Definition. . . . . . . . . . . . . . . . . . 326 Constructors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 Section 12.2 Writing Methods . . . . . . 337 Accessor Methods . . . . . . . . . . . . . . . . . . . . . . . . 337 xiv