COP 2210 Laboratory 8 - Java “Documentation Comments” and Packages

Partner 1 Name and Section: ______

Partner 2 Name and Section: ______

Objectives:

w  To practice creating and using packages

w  To practice writing Java documentation comments for our classes, methods, parameters,

and return values, and creating the html “help” pages

Begin by downloading these 2 files from the class web page and storing them in the src folder of your project:

Circle.java Time.java

Exercise 1:

F  Refer to the online documents “Packages” and “Using the Javadoc Utility in NetBeans” for detailed instructions

  1. Open and examine Circle.java. Note the Java “documentation comments” for the class and for each method, parameter, and return value
  1. Create a package with an appropriate name in the src folder of your project
  1. Using the Refactor command, move Circle.java into your package folder
  1. Generate the html “help” pages for the Circle class

F  From the Run menu, choose “Generate Javadoc”

  1. Open the file Circle.html in your browser and note how each documentation comment appears in the web page (in the NetBeans Files pane, right-click on the Circle.html icon and click View)

F  Circle.html will be found in a folder with the same name as your package folder, in a folder called javadoc, in the newly-created dist folder

  1. Open the file CircleTest.java and note that NetBeans has added the necessary import statement. Also note that the required package statement has been added to Circle.java

Check: ______

Exercise 2:

F  If necessary, refer to the online document “Java Documentation Comments”

  1. Open Time.java and carefully read the comments describing the class and its methods
  1. Using Circle.java for reference, add the proper Java documentation comments to the Time class. Be sure to document the class and every method, parameter, and return value
  1. Create another package with an appropriate name in the src folder of your project
  1. Using the Refactor command, move Time.java into your new package folder
  1. Generate the html “help” pages for the Time class
  1. Open the file Time.html in your browser (or NetBeans) and make sure all of the necessary information appears. If not, correct the documentation comments (or add the missing ones) and create the html file again
  1. Note that the required package statement has been added to Time.java

Check: ______