Make your own free website on Tripod.com

 

Welcome to Petar Knezevich's Javadoc Page

Javadoc allows for the creation of complex and comprehensive comments and documentation for your Java code. If you use Javadoc from the moment you start coding, you will greatly improve your popularity with anyone who will use your code.

Here are the html pages generated by javadoc on this Java code (minus the advertising of course). The command line used to create them was:

javadoc -d destination_dir Circle.java

Save this code in a file named Circle.java and then run the command line given above.


/**
 * This class represents a Point as an x,y pair.
 *
 * @author Petar Knezevich
 * @version 0.9.1
 */
public class Point {
 /**
  * Holds the x coordinate.
  */
 public double x;
 /**
  * Holds the y coordinate.
  */
 public double y;
 
 /**
  * Default class constructor creates a point at the origin.
  *
  * @param x The x cooridinate.
  * @param y The y cooridinate.
  */
 public Point(){
  this.x = 0;
  this.y = 0;
 }
 /**
  * Class constructor creates a point at the given coordinate.
  *
  * @param x The x cooridinate.
  * @param y The y cooridinate.
  */
 public Point(double x, double y){
  this.x = x;
  this.y = y;
 }

 /**
  * Returns the distance of the point from the origin.
  *
  * @return A double that is the distance from the origin.
  */
 public double distance(){
  return Math.sqrt(this.x*this.x + this.y*this.y);
 }
 /**
  * Returns the distance of pt from this point.
  *
  * @return A double that is the distance of pt from this point.
  */
 public double distance(Point pt){
  return Math.sqrt(Math.pow((this.x-pt.x),2) + Math.pow((this.y-pt.y),2));
 }
 /**
  * Assigns the value of coordinates x and y
  * to this point.
  */
 public void assign(double x, double y){
  this.x = x;
  this.y = y;
 }
 /**
  * Assigns the value of pt to this point.
  */
 public void assign(Point pt){
  this.x = pt.x;
  this.y = pt.y;
 }
 /**
  * Method used by Java to convert from Point to
  * string.  Useful when debugging.
  *
  * @return A String that is used when printing Point.
  */
 public String toString(){
  return "Point value is (x,y) = (" +this.x+ "," +this.y+ ")";
 }
}




/**
 * This class represents a Line as a Point pair.
 *
 * @author Petar Knezevich
 * @version 0.9.1
 */
public class Line{
 /**
  * Holds the start point.
  *
  * @see start
  */
 Point start = new Point(0,0);
 /**
  * Holds the end point.
  *
  * @see end
  */
 Point end = new Point(1,1);

 /**
  * Default constructor creates a unit Line.
  */
 Line(){}
 /**
  * Constructor, defined via two Points.
  *
  * @param start Start of line.
  * @param end End of line.
  */
 Line(Point start, Point end){
  this.start = start;
  this.end   = end;
 }
 /**
  * Constructor, defined via start cooridinates and an end
  * Points.
  *
  * @param start Start of line.
  * @param x End of line x coordinate.
  * @param y End of line y coordinate.
  */
 Line(Point start, double x, double y){
  this.start = start;
  this.end.x = x;
  this.end.y = y;
 }
 /**
  * Constructor, defined via a start Point and end
  * cooridinates.
  *
  * @param x Start of line x coordinate.
  * @param y Start of line y coordinate.
  * @param end End of line.
  */
 Line(double x, double y, Point end){
  this.start.x = x;
  this.start.y = y;
  this.end     = end;
 }
 /**
  * Constructor, defined via a start and end cooridinates.
  *
  * @param x1 Start of line x1 coordinate.
  * @param y1 Start of line y1 coordinate.
  * @param x2 End of line x2 coordinate.
  * @param y2 End of line y2 coordinate.
  */
 Line(double x1, double y1, double x2, double y2){
  this.start.x = x1;
  this.start.y = y1;
  this.end.x   = x2;
  this.end.y   = y2;
 }

 /**
  * Returns the length of the Line.
  *
  * @return A double that is the length of the Line.
  */
 public double length(){
  return Math.sqrt(Math.pow((this.start.x-this.end.x),2) + \
                           Math.pow((this.start.y-this.end.y),2));
 }

 /**
  * Method used by Java to convert from Line to
  * string.  Useful when debugging.
  *
  * @return A String that is used when printing Line.
  */
 public String toString(){
  return "Line value is (pt.x,pt.y) = (" +this.start+ "," +this.end+ ")";
 }
}




/**
 * This class represents a Circle as a center/radius
 * (Point,Line) pair.
 *
 * @author Petar Knezevich
 * @version 0.9.1
 */
public class Circle{
 /**
  * Holds the center Point.
  *
  * @see center
  */
 Point center = new Point(0,0);
 /**
  * Holds the radius Line.
  *
  * @see radius
  */
 Line  radius = new Line(0,0,1,1);

 /**
  * Default constructor creates a unit circle centered at the origin.
  */
 Circle(){}
 /**
  * Constructor, defined via a radius Line, centered
  * at the origin.
  *
  * @param radius Radius of circle.
  */
 Circle(Line radius){
  this.center.x = 0;
  this.center.y = 0;
  this.radius.start.x = radius.start.x;
  this.radius.start.y = radius.start.y;
  this.radius.end.x = radius.end.x;
  this.radius.end.y = radius.end.y;
 }
 /**
  * Constructor, defined via a center Point and
  * a radius Line.
  *
  * @param center Center of circle.
  * @param radius Radius of circle.
  */
 Circle(Point center, Line radius){
  this.center = center;
  this.radius = radius; 
 }

 /**
  * Method used by Java to convert from Circle to
  * string.  Useful when debugging.
  *
  * @return A String that is used when printing Circle.
  */
 public String toString(){
  return "Circle value is a center/radius pair (pt,line) = ("
  +this.center+ "," +this.radius.length()+")";
 }

 /**
  * Returns the area of the Circle.
  *
  * @return A double that is the area of the Circle.
  */
 public double area(){
  return (Math.PI * this.radius.length() * this.radius.length());
 }
}

Here are the html pages generated by javadoc (minus the advertising of course). Here is a list of Javadoc tags.

You can go back to front.