Download presentation
Presentation is loading. Please wait.
Published byCharlene Sanders Modified over 9 years ago
1
Georgia Institute of Technology Creating Classes part 4 Barb Ericson Georgia Institute of Technology May 2006
2
Georgia Institute of Technology Learning Goals Computing concepts –Comments Why add comments? Types of comments How to add Javadoc comments How to preview HTML from Javadoc comments How to create HTML for all classes in a directory –Creating another class Using UML to show classes and the relationships between them
3
Georgia Institute of Technology Comments You should add comments to your code –To make it easier to read and change Comments are ignored by the complier –Not added to the byte codes Java has 3 kinds of comments –// comment ends at the end of this line –/* comment ends with next */ –/** Javadoc comment that ends with */ can be used by the javadoc utility to create HTML documentation
4
Georgia Institute of Technology Javadoc Comments Add a comment before the class definition –That explains the purpose of this class –And says who wrote it @author Barb Ericson /** * Class that represents a slide show. A slide show has * an array of pictures, a time to wait between pictures, * and a title that is shown at the beginning of the show. * * @author Barb Ericson */ public class SlideShow
5
Georgia Institute of Technology Method Comments Add a comment before each method What the parameters are –@param name info What is returned –@return info /** * Method to change the time to wait * between pictures * @param time the new time to use * in milliseconds */ public void setWaitTime(int time) { if (time >= 0) this.waitTime = time; }
6
Georgia Institute of Technology Previewing Javadoc HTML Click on Tools Click on Preview Javadoc for Current Document –This will generate the HTML from the javadoc comments and display it The HTML document will display
7
Georgia Institute of Technology Generating all HTML for Directory In DrJava click on the Javadoc button –to create the HTML documentation –based on the Javadoc comments This will generate HTML for all files in the same directory as all open files Generates an index.html as a starting point
8
Georgia Institute of Technology Javadoc Exercise Add a class javadoc comment and method javadoc comments to the SlideShow class Execute Javadoc and check out the created documentation
9
Georgia Institute of Technology Summary Comments are added to make a program –Easier to read and understand –Comments are ignored by the compiler There are three types of comments in Java –// end of line –/* multi line */ –/** java doc */ Javadoc is a utility that comes with the jdk –Produces HTML documentation from Javadoc comments
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.