Programs for INTRODUCTION TO PROGRAMMING USING JAVA 
Copyright (c) 2010 Jones & Bartlett

Disclaimer                                                    
----------

The included programs are provided to you on an "as is" basis for 
instructional purposes only, without any warranties, expressed or 
implied.  The author and publisher shall not be liable in any 
event for incidental, consequential, special, or punitive damages 
in connection with, or arising out of the distribution, 
performance, or use of the included programs.          


Which files are available
-------------------------

All the Java code that appears in the textbook, including the 
code in the prep, lab, and homework exercises, is in this 
collection.  

The file names of the sample programs from the textbook match the 
class names of the classes that contains the main method.  For 
example, the Program1 class that appears in Chapter 1 is in the 
file Program1.java.  

The file names for the exercises include the chapter number, the 
category letter ("p" for prep, "e" for lab exercise, and "h" for 
homework), and the exercise number.  For example, the file 
C1p4.java is for Chapter 1 Lab Prep 4; C1e5.java is for Chapter 1 
Lab Exercise 5; C6h1.java is for Chapter 6 Homework 1. 


End-of-line marker
------------------

All the Java files included have lines that are terminated using 
the Microsoft approach--that is, with the carriage return/newline 
sequence.  This format does not cause any problems with javac, 
BlueJ, and DrJava programs on any of the standard platforms. Some 
text editors on non-Microsoft systems, however, may display or 
print garbage characters for the carriage return characters.  If 
this happens with the text editor you are using, try switching 
text editors.  Alternatively, you can use a utility program to 
remove the carriage return characters.  For example, on Linux, 
the following command 

fromdos *.java

removes carriage returns from all the java files in the current 
folder. 


Three formats provided
----------------------

The Java code included is provided in three formats, each in a separate 
folder, so that no matter what programming environment you use, 
at least one of the formats should be suitable.  The three 
folders are: 

     1) fromtext - Contains the Java code as it appears in the 
        textbook but without line numbers.  Each program is in a 
        single file. 

     2) ide - Contains a separate folder for each program 
        with each class in a separate file. 

     3) mainfirst - Contains the Java code in the textbook but 
        with the class containing main first.  Each program is in a 
        single file.          


Which format should you use
---------------------------

If you use javac on the the command line, use the programs in 
the fromtext folder. 

If you use BlueJ or DrJava, use the programs in the ide folder. 

In BlueJ, you can easily convert every folder in the ide folder 
to a BlueJ project simply by clicking on "Project", then clicking 
on "Open Non BlueJ...", and selecting the folder containing the 
program you want to use.  BlueJ will then convert that folder into 
a BlueJ project. When BlueJ displays the class structure, you may 
want to relocate the class icons (by dragging) so that the arrows 
representing the class structure are clearly displayed. I suggest 
you drag the icons so that the solid arrows (representing 
inheritance) are pointing up.  On the second and subsequent uses 
of a program, open it by clicking on "Project" and then on "Open 
BlueJ...". 

In DrJava, click on the Open button.  Then open the folder that 
contains the program your want to run.  Click on the files that 
make up the program (hold down the Ctrl key after the first 
click).  Then click on "Open"in the Open window.  To compile, 
click on the Compile button.  To run, click on the file that has 
the main method.  Then click on the Run button.    

If you want to use programs in single-file format (i.e., with all 
the classes of a program in a single file), you may find that 
your IDE does not work unless the class with main appears first.  
If this is the case, use the programs in the mainfirst folder. 
