Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Exposure Java 2014 Table of Contents Chapters I - X I Introduction to Computer Science 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 IIa 2a.1 2a.2 2a.3 2a.4 2a.5 2a.6 IIb 2b.1 2b.2 2b.3 2b.4 2b.5 2b.6 2b.7 2b.8 2b.9 2b.10 2b.11 Learning the Exposure Way . . . . . . Exposure Equation . . . . . . . . . Getting Started . . . . . . . . . . . How Do Computers Work? . . . . . . Messages with Morse Code . . . . . . Electronic Memory . . . . . . . . . Memory and Storage . . . . . . . . . Hardware and Software . . . . . . . . A “Brief” History of Computers. . . . . . What Is Programming? . . . . . . . . A “Brief” History of Programming Languages Networking . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4 7 8 9 11 15 18 20 41 42 49 52 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 58 63 68 72 79 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 83 83 85 88 89 91 97 100 104 111 Introduction to NXT Introduction . . . . . . . . . . . Loading and Executing an NXT Program . The Sequence Beam and Program Blocks Configuring the Display and Wait Blocks . Configuring the Move Block . . . . . Program Comments . . . . . . . . Introduction to Java Introduction . . . . . . . . . Getting Started with Java . . . . A Visit to the United Nations . . . Java Bytecode . . . . . . . . Applications and Applets . . . . Using Java Software . . . . . . Text Output With print & println . . Program Compile Errors . . . . . Program Comments . . . . . . The Responsible Use of Computers NXT and Java Comparison . . . . . . . . . . . . . . . . . . . . . . . . . Table of Contents . . . . . Chapters 1-10 i IIIa 3a.1 3a.2 3a.3 3a.4 3a.5 3a.6 IIIb 3b.1 3b.2 3b.3 3b.4 3b.5 3b.6 3b.7 3b.8 3b.9 3b.10 3b.11 3b.12 IVa 4a.1 4a.2 4a.3 4a.4 4a.5 4a.6 IVb 4b.1 4b.2 4b.3 4b.4 4b.5 4b.6 4b.7 4b.8 4b.9 4b.10 4b.11 ii Variables and Constants Introduction . . . . . . . . . . . The NXT Variable Block . . . . . . . Using Data Wires to transfer Data Values Binary Operations with the Math Block . String Concatenation with the Text Block The NXT Constant Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 127 131 136 140 144 Java Simple Data Types Introduction . . . . . . Storing Data Information . Declaring Variables in Java The int Data Type . . . . The double Data Type . . The String Data Type . . . The char Data Type . . . The boolean Data Type . . Declaring Constants in Java. Documenting Your Programs Mathematical Precedence . NXT and Java Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 151 152 155 159 161 163 164 165 166 170 173 Introduction . . . . . . . . . Using Math Block Functions . . . The Random Block . . . . . . Graphics and Coordinate Geometry The Display Block Revisited . . . The Sound Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 186 191 196 197 201 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 205 208 216 217 223 230 234 237 242 244 Blocks and Data Hubs Java Program Organization Introduction . . . . . . . . . Java Program Components . . . Using the Math Class . . . . . Introduction to the Expo Class . . Graphics and Coordinate Geometry Drawing Methods . . . . . . . Fill Methods and Graphics Colors . The random Method . . . . . . Drawing Polygons . . . . . . . Expo Class Reference Information . NXT and Java Comparison . . . First Exposure 2014 06-06-14 Va 5a.1 5a.2 5a.3 5a.4 5a.5 5a.6 5a.7 5a.8 5a.9 Vb 5b.1 5b.2 5b.3 5b.4 5b.5 5b.6 5b.7 5b.8 5b.9 5b.10 5b.11 5b.12 VIa 6a.1 6a.2 6a.3 6a.4 6a.5 6a.6 6a.7 6a.8 6a.9 Repetition with the Loop Block Introduction . . . . . . . . . Fixed Repetition with the Loop Block Using the Loop Control Variable . . Using the Loop Block with Wait . . Nested Looping . . . . . . . . Nested Loops and Data Wires . . Using Sound in a Loop Block . . . Conditional Looping . . . . . . Using the Loop Block with Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 253 256 258 259 262 264 266 269 Introduction . . . . . . . . . . . . . . Fixed Repetition with for. . . . . . . . . . Using the Loop Control Variable . . . . . . . Nested Loops . . . . . . . . . . . . . Keyboard Input with Expo.enterInt . . . . . . Conditional Repetition with do…while . . . . . Repetition and Graphics. . . . . . . . . . Displaying Graphics Characters . . . . . . . Drawing Regular Polygons . . . . . . . . . Creating New Colors . . . . . . . . . . . Using Random Numbers with graphics in a Loop . NXT and Java Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 274 278 281 286 287 291 297 301 305 308 315 . . . . . . . . . . . . . . . . . . 326 328 339 344 351 355 359 372 376 Java Repetition Class Methods and Object Methods Introduction . . . . . . . . . . . . . . . . Creating Simple Program Blocks . . . . . . . . Program Blocks with Input Information . . . . . . Program Blocks with Multiple Input Information . . . Program Blocks with Output Information . . . . . . Program Blocks with Input & Output Information . . . Using My Blocks to Create a My Block . . . . . . User Input with the EnterIntNXT My Block . . . . . Creating a Practical Program with Just a Few My Blocks Table of Contents Chapters 1-10 iii VIb 6b.1 6b.2 6b.3 6b.4 6b.5 6b.6 6b.7 6b.8 6b.9 6b.10 VIIa 7a.1 7a.2 7a.3 7a.4 7a.5 7a.6 7a.7 7a.8 7a.9 VIIb 7b.1 7b.2 7b.3 7b.4 7b.5 7b.6 7b.7 7b.8 7b.9 7b.10 7b.11 iv Class Methods and Object Methods Introduction . . . . . . . . . . . . . Creating Simple Methods . . . . . . . . Graphics Programs with Multiple Methods . . Creating a Big Graphics Program Step-By-Step Void Methods with a Single Parameter . . . Void Methods with Multiple Parameters . . . Return Methods with a Single Parameter . . Return Methods with Multiple Parameters . . Creating Methods with Other Methods . . . NXT and Java Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 383 392 409 417 422 430 432 436 443 Decision Making in NXT Introduction . . . . . . . . Switch Block Settings . . . . . One-Way Selection . . . . . Two-Way Selection . . . . . Nested Control Structures . . . Multi-Way Selection . . . . . Compound Conditions . . . . Ranges . . . . . . . . . . Compound Compound Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 459 461 463 465 468 471 476 479 Introduction . . . . . . . . . . . Relational Operators . . . . . . . . One-Way Selection . . . . . . . . Two-Way Selection . . . . . . . . Nested Control Structures . . . . . . Multiple-Way Selection . . . . . . . The boolean Data Type . . . . . . . Compound Conditions . . . . . . . Ranges . . . . . . . . . . . . . Protecting Against user Data Entry Errors NXT and Java Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 484 487 492 495 504 518 521 530 534 536 Decision Making in Java First Exposure 2014 06-06-14 VIII Using Sensors in NXT 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 Introduction . . . . . . Sensor Blocks in Lego NXT The Touch Sensor . . . . The Sound Sensor . . . . The Light Sensor . . . . The Ultrasonic Sensor . . The NXT Button Sensor . . The Rotation Sensor . . . Combining Sensors . . . IXa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550 554 556 563 566 568 574 578 583 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588 590 591 596 597 599 600 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604 605 610 616 619 628 631 633 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 636 644 650 670 680 683 700 712 726 File Handling in NXT 9a.1 9a.2 9a.3 9a.4 9a.5 9a.6 9a.7 Introduction . . . . . . . . . . Different Types of Files . . . . . . The File Access Block . . . . . . Storing and Retrieving Text Data . . Files with Multiple Lines of Data . . . Retrieving Data with a Conditional Loop Data Files that Store Numbers . . . IXb Object Methods and Text Files 9b.1 9b.2 9b.3 9b.4 9b.5 9b.6 9b.7 9b.8 X . . . . . . . . . Introduction . . . . . . . . . Classes and Objects . . . . . . Using Object Methods . . . . . Using the DecimalFormat Class . . Reading In Text Files . . . . . . Writing Out Text Files . . . . . Reading and Writing Simultaneously Summary . . . . . . . . . . . . . . . . . . Intermediate Graphics 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 Introduction . . . . . . . . . . . Using Mouse Events . . . . . . . . Importing Images . . . . . . . . . Fixing Image Issues . . . . . . . . New Features with the Deluxe Expo Class Multi-Page Output . . . . . . . . . Creating a Simple Draw Program . . . Creating Clickable Areas in the Applet . Computer Animation . . . . . . . . The Last Word . . . . . . . . . . Table of Contents Chapters 1-10 v vi First Exposure 2014 06-06-14