cp -r ~mc28/labs/java/java .(Note that this command ends with a space and then a period. Ask for help with this if you need it.) You will get a new directory called
java. This directory contains three subdirectories, one for each portion of the lab. All the individual java files you will use are in one of those subdirectories.
ItemList.javathe class that holds the Items the customer is ordering
Item.javathe base class for different kinds of clothing items, specifically
CompuDuds.javathis is the main program class; it has no instances but has a number of important ``static'' methods (i.e., methods that class-wide, not associated with a specific instance).
To compile and run the program, you'll need to work in a shell (terminal) window. First you'll need to change directory into the directory where you have the files, e.g.
cd java/CompuDudsNow you can compile each of the files; for example, to compile ItemList.java, you'd use the command
javac ItemList.javaYou need to do the corresponding command for each of the other four files as well. The most important thing to remember is this: if you make any change to any of the files, you must recompile that particular file before you can test the program, and you must save it out of the editor before you recompile it. In other words, after making any change, you have to save, then compile, then test. (You will be using an editor of your choice to edit the java files; we suggest emacs. Be sure to ask for help with emacs if you need it.) When you add a new class, it should go in a file of its own, named after the class. You should then compile that new file as well.
Once you have the five original files compiled, the first thing to do is to test the program out without yet having made any changes. That way you have a baseline for comparison: if it isn't working, you aren't the one who broke it. To run the program, use the command
Now you can start making the necessary changes, and test and debug as you go along. Perform exercises 15.2 through 15.4 on pages 598-599 of the text.
cd ../puzzlebecause .. is a name for the "parent" of the current directory. That is, if you are down in the CompuDuds directory, .. is the java directory and ../puzzle is its puzzle subdirectory.
To run the code, first compile all of the Java files with
javac *.javaand then run the appletviewer on the HTML file:
appletviewer puzzle.htmlOnce tested, add the ``Randomize'' button described on in Exercise 15.8 on page 615.