Java Reference
In-Depth Information
public String getDescription()
{
}
/**
Gets the product price.
@return
the unit price
*/
public double getPrice()
{
}
}
/**
Describes a mailing address.
*/
public class Address
{
/**
Formats the address.
@return
the address as a string with three lines
*/
public String format()
{
}
}
549
550
Then run the
javadoc
program to obtain a prettily formatted version of your
documentation in HTML format (see
Figure 8
).
This approach for documenting your classes has a number of advantages. You can
share the HTML documentation with others if you work in a team. You use a
format that is immediately usefulȌJava source files that you can carry into the
implementation phase. And, most importantly, you supply the comments of the key
methodsȌa task that less prepared programmers leave for later, and then often
neglect for lack of time.
12.4.5 Implementation
Finally, you are ready to implement the classes.
You already have the method signatures and comments from the previous step.
Now look at the UML diagram to add instance fields. Aggregated classes yield