![]() |
![]() |
|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
You've (hopefully) noticed in the code presented in class, the function is preceded by comments, and the comments have kinda a funny format, what with those “@” signs. The comments are in a special format, called “javadoc”. They explain what the parameters numPizzas and size mean, and what the returned answer means. They help people understand your program, without having to read the bare code.
There is a bonus to writing this information using those tags @param and @return: In BlueJ, select Tools > Project Documentation Voila! Other programmers can look at this web page for pizzaServer, and know how to call our functions, without ever actually having to look at our code!
Tip: I addition to having a javadoc comment in front of each function/method, you can put a comment at the start of your entire file, preceding the class declaration itself. You won't have “param” or “return” keywords, but instead you describe the overall class, and include your name with the “@author” tag:
/** A class to demonstrate some javadoc comments. * @see http://www.radford.edu/itec120/2008spring/Lectures/lect02-javadoc.html * @author Ian Barland * @version 2008.Jan.26 */ class DemoDummy { /** A method to square a number. * @param x the number to be squared. * @return x^2. * * Examples, if dd is an instance of DemoDummy: * dd.square( 0 ) = 0 * dd.square( 1 ) = 1 * dd.square( 2 ) = 4 * dd.square( 1.5 ) = 2.25 * dd.square( 10 ) = 100.0 */ double square( double x ) { return x*x; } } |
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2008, Ian Barland, Radford University Last modified 2008.Jan.26 (Sat) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |