Wednesday, June 16, 2004

Exercise[25]

When working with non-trivial amounts of code, it's common to partition the code and save the pieces in separate files. Code and the files that contain the code need to be carefully organized. And files need to be somehow related to each other when there are dependencies between pieces of code they contain. This exercise provides practice taking existing code not yet stored in files, placing it in files, and verifying that the code can then be used as intended. The exercise also sets up exploration of programming topics related to the stopwatch code.

Make a One-Button Stopwatch


Notice how the JavaScript and Java code shown in One-Button Stopwatch is partitioned. Using a text editor, place the code snippets into separate files. Name the files and place the files in particular directories as suggested by the headers above each section of code and as described below.

If you're working with the JavaScript code, all of the files should be placed in a single directory and should have the same name as the header above the section of code. Load the Stopwatch.html file using a web browser.

If you're working with the Java code, then the file named Stopwatch.java should be placed in a directory that contains a directory named com; the com directory should contain a directory named blogspot; and the blogspot directory should contain a directory named finnegantakes. The other .java files should be placed in the finnegantakes directory. Compile all of the .java files and interpret the Stopwatch class.

Recommended Reading


AP Computer Science Principles - JavaScript
AP Computer Science A - Java