Javadoc Example

Java has a documentation tool called Javadoc that you can use to generate well-formatted external documentation of your classes. Below is an example of a class that is documented in the Javadoc style; you can see the documentation that it generates here.

/**This class models a line in a two-dimensional space.
 * @author CS133 Staff
 */
public class Line
{   
  private double slope;
  private double yIntercept;
  
  /**Constructs a Line by initializing the slope and 
   * yIntercept instance variables.
   * @param slope The slope of this Line.
   * @param yIntercept The y-coordinate of the y-intercept of this Line.
   */
  public Line(double slope, double yIntercept)
  {   
  }
  
  /**Returns the x-intercept of this Line.
   * @return This Line's x-intercept.
   */
  public double getXIntercept()
  {   
  }
  
  /**Returns the y-intercept of this Line.
   * @return This Line's y-intercept.
   */    
  public double getYIntercept()
  {   
  }
  
  /**Returns the slope of this Line.
   * @return This Line's slope.
   */    
  public double getSlope()
  {
  }
  
  /**Returns a String representation of this Line in
   * y = mx + b format where m is the slope and b is the y-intercept.
   * @return The equation of this Line.
   */      
  public String toString()
  {   
  }
  
  /**Changes the position of this Line by shifting it yShift units vertically
   * @param yShift The number of units to shift the Line.
   */  
  public void shiftVertical(int yShift)
  {
  }
  
  /**Changes this line to be its reflection in the line y = x.
   */
  public void invert()
  { 
  }
  
  /**Treats this Line as a function and evaluates its y-value at the 
   * x-value given.
   * @param xPosition The x-value at which to evaluate the function.
   * @return The value of y when this Line passes through xPosition.
   */
  public double evaluateAt(double xPosition)
  {   
  }
  
}