Preparing and Submitting Files of Java Source Code

Click here for a WordPerfect version of this document.

Click here for a MS WORD version of this document.

Click here for a PDF version of this document.

 

1.   One class = One *.java File: Save the source code for each class to a separate *.java file. Do not place multiple classes in a single file. Although Java syntax permits multiple classes to be saved to a single file, placing each class in a separate file supports modularization.


Note: Always have a separate GUI class rather than integrating GUI code with other classes.

 

2.   ID Header: An ID Header should provide the same categories of information as in the following example. Insert it at the beginning of every class (file) of Java source code.


/*****************************************************************************
Class: NewDialog                             Program:HardwareStore

Date:October 4, 2003 Exercise:16.10

Purpose:Create GUI dialog: get values from user & set them in a new record.

Author:Student StupendousTeacher:Gerry Donaldson

School:Sir Winston Churchill High School, Calgary, Alberta, Canada

Text:Deitel, Harvey & Paul, JAVA HOW TO PROGRAM 4th Edition, Prentice
Hall, Upper Saddle River, New Jersey, 2002. ISBN:0-13-0345151-7.

Language:   Java2 SDK 1.4.1 System:Intel Pentium IV running under Windows XP

*****************************************************************************/

 

3.   Follow Sun Microsystems' conventions for unique package names. See line 16 below.

  a. School's internet domain name in reverse order: ca.ab.cbe

  b. School Web Page Directory: b857 = Sir Winston Churchill High School

  c. Program within the school: ib = International Baccalaureate

  d. Course taken within that program: cs31ib = Computer Science 31-IB

  e. Initials of programmer/student: gdd = Gerry Douglas Donaldson

  f. Location of exercise: jhtp4 = Java How to Program: Fourth Edition

  g. Chapter & exercise numbers: c16e10 = chapter 16, exercise 10

  h. The "wild card" asterisk "*" references all files in the path.


1.   // Java core packages

2.   import java.awt.*;

3.   import java.io.*;

4.   import java.awt.event.*;

5.   

6.   // Java extension packages

7.   import javax.swing.*;

8.   

9.   // LOCATION OF DIRECTORY WITH LOCALLY DEVELOPED SOURCE CODE:

10.  // (See explanation of path in foregoing comments.)

11.  // class DeleteDialog.java

12.  // class InventoryDialog.java

13.  // class NewDialog.java

14.  // class Record.java

15.  // class UpdateDialog.java

16.  import ca.ab.cbe.b857.ib.cs31ib.gdd.jhtp4.c16e10.*;

 

4.   Create a path of nested directories that corresponds to the "path" name of the package.

 

"ca.ab.cbe.b857.ib.cs31ib.gdd.jhtp4.c16e10.*;" requires a separate directory for each of the following names in the package path.

 

ca -> ab -> cbe -> b857 -> ib -> cs31ib -> gdd -> jhtp4 -> c16e10

 

5.   Before compiling, save files of imported classes to the deepest directory. In the above example, all *.java files except the main *.java file is saved to the following directory:


ca.ab.cbe.b857.ib.cs31ib.gdd.jhtp4.c16e10

 

6.   Copy the source code of each *.java (class) file to a separate wordprocessing file.

 

      a.    Use a non-proportional such as Courier New to maintain the original indentation.

 

Adjust the font's size and the width of side margins to accommodate the new font.

 

      b.    Number all lines including blank lines beginning with the first line of source code.

 

Do not number the lines of the ID header.

 

(WordPerfect 10: Select line to be numbered -> Format -> Line -> Numbering... )

 

      c.    Place a footer with a horizontal line that separates the footer from the body of the page. The footer contains the class name on the left, automatic page numbering in the centre, and the program name on the right. See the following example of an appropriate footer.

_______________________________________________________________________
Class: NewDialog                             Page 2 of 5                             Program: HardwareStore

 

(WordPerfect 10: Move cursor to beginning of document -> Insert -> Header/Footer... -> Select "Footer A" -> Create -> Create horizontal line with Insert -> Line -> Horizontal Line -> Press enter to move cursor to the next line -> Type "Class: NameOfClass" -> Move cursor to center of line: simultaneously press Shift and F7 -> Type "Page" -> Format -> Page -> Numbering... -> Select "Page" -> Insert -> Close -> Type " of " -> Format -> Page -> Numbering... -> Select Total Pages -> Insert -> Close -> Move cursor to far right of line by simultaneously pressing Alt and F7 -> Type "Program: NameOfPrg"-> Escape footer by clicking elsewhere.)

 

      d.    Insert screen dumps associated with a class below the source code of that class.

 

Place one or more screen dumps of a single class below the source code of that class.

 

Place all screen dumps of an entire program below the source code of the main class.

 

To capture a screen dump of a frame, select the frame, simultaneously press the Alt and PrtScn keys, select the wordprocessing window, press Ctrl-V to copy the screen buffer.

 

Screen dumps may be resized and set behind text when placing them on a wordpro page.

 

7.   Print each finished wordprocessed files at two pages per side on both sides of the paper.


[Counter On Strike [Home of Gerry Donaldson's Com Sci Gate]
[Gerry Donaldson's Email Address]
csgate@donaldson.org
ICQ# 62833374
[EFC Blue Ribbon - Free Speech Online]

URL:   http://www.donaldson.org/    Last Revised:   October 5, 2003