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.
To run BlueJ, in a shell window type
bluej &There will be all sorts of error messages in the shell window about fonts not being found; these are a consequence of how our Java software was installed and don't cause any particular problems other than looking alarming. In fact, you may want to miniaturize the shell window, since the error messages can get rather annoying.
Three of the four portions of the lab correspond to a separate "project" in BlueJ, and are contained in separate subdirectories. (You will create the fourth project, corresponding to the new java puzzle, ourself.) You will open each of them from within BlueJ, using the Project menu's "Open Project..." option. They are all found within the java directory you copied. More specifics about each project are in the following sections of this lab handout.
When you open a project, BlueJ will show a UML diagram of its classes. The style of diagram it uses is very cluttered with dotted arrows between classes; these dotted arrows indicate that one class makes some use of the other class. To unclutter the diagram, you can turn these arrows off, by clicking the checkbox labeled "Uses".
To perform any operation on any class or object shown in BlueJ, you can use the right mouse button to click on it. This will bring up a menu of the different operations you can perform. One operation on classes is so common that there is also a shortcut: to open a class in the editor, you can just use the left mouse button to double click on the class.
BlueJ's text editor has only limited support for indentation. Unlike DrScheme, it will not automatically indent each line the correct amount. Instead it will indent each new line the same amount as the line above it. You can indent in further using the tab key, or back out with the backspace. You can also select a block of lines with the mouse and then move that whole block left or right using the F5 or F6 key.
Note that printing from BlueJ doesn't seem to be working at the moment. To work around this, you can print Java files using shell commands. For example, you could do
mpage -2f java/CompuDuds/ItemList.java | lpr -Pmcslab
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).
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,
right-click on the
CompuDuds class and select the
main method. In addition to running the program in this
way, you can try making and interacting with individual objects
directly through BlueJ, as demonstrated in class. This will be
valuable in the testing and debugging you do later in this part of the
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 as well as exercise 15.20 on pages 640-641 of the text. For exercise 15.3, you will need to make a new class that is very similar to one of the existing classes. In order to do this the easy way, use BlueJ's button to make a New Class, which will be initially empty. Then open both that new class and one of the old classes up in the editor, and use the mouse to select the contents of the old class, copy them, and paste them into the new class. Now edit the new class to differ from the old one as appropriate.
For exercises 15.2, 15.4, and 15.20, you should simply modify the class ItemList. In particular, if you should not create a new class called ThriftyItemList like you did in homework exercise 14.18. Furthermore, when submitting this part of the project, just submit the final form of the CompuDuds directory, which contains all the changes for the four exercises together.
sleepcommands and the
synchronizekeywords in your code. (The
synchronizeshould get rid of the problems exposed by the calls to
The gradesheet for the project is available in PostScript or PDF format. (If you print a copy out, you can staple it to the front of your project report to save paper.)
CompuDudsportion, you should write a
ItemListwhich does the testing. Make sure that you have generated the right documentation files and that they look good. Note that you can generate the documentation files directly from bluej.
emacsif you wish.
cdto the directory containing the java directory whcih contains the four portions (subdirecotories) of the lab, and type
lsto make sure you are in the right place. Finally, type: