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
~mc28/labs/java/bluej/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.
Each of the three portions of the lab corresponds to a separate "project" in BlueJ. 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 the 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 de-clutter 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 -Pmcs-lab
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
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 lab.
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. You will probably find yourself wanting 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.