Java |
single-line-comment:
// input-charactersopt
multiple-line-comment:
/* .... */
/** documentation */
javadoc format
an example
you may need html format not xml format.
package Graphics;
/** Class Point models a point in a two-dimensional plane.
*/
public class Point
{
/** Instance variable x represents the point's
x-coordinate.
*/
private int X;
/** Instance variable y represents the point's
y-coordinate.
*/
private int Y;
/** Property X represents the point's x-coordinate.
*/
public int getX() {return X; }
public void setX(int value) { X = value; }
/** Property Y represents the point's y-coordinate.
*/
public int getY() {
return Y;
}
public void setY(int value) { Y = value; }
/** This constructor initializes the new Point to
(0,0).
*/
public Point(){ this(0,0); }
/** This constructor initializes the new Point to
xor, yor.
<P>xor is the new Point's x-coordinate.
<P>yor is the new Point's y-coordinate.
*/
public Point(int xor, int yor) {
X = xor;
Y = yor;
}
/** This method changes the point's location to
the given coordinates.
<P>xor is the new x-coordinate.
<p>yor is the new y-coordinate.
@see Translate
*/
public void Move(int xor, int yor) {
X = xor;
Y = yor;
}
/** This method changes the point's location by
the given x- and y-offsets.
<p>For example:
<pre>
Point p = new Point(3,5);
p.Translate(-1,3);
</pre>
results in p's having the value (2,8).
<p>
<p>xor is the relative x-offset.
<p>yor is the relative y-offset.
@see Move
*/
public void Translate(int xor, int yor) {
X += xor;
Y += yor;
}
/** This method determines whether two Points have the same
location.
<p>o is the object to be compared to the current object.
<P> True if the Points have the same location and they have
the exact same type; otherwise, false.
*/
public boolean locationEquals(Object o) {
if (o == null) {
return false;
}
if (this == o) {
return true;
}
if (getClass() == o.getClass()) {
Point p = (Point)o;
return (X == p.X) && (Y == p.Y);
}
return false;
}
/** Report a point's location as a string.
A string representing a point's location, in the form (x,y),
without any leading, training, or embedded whitespace.
*/
public String toString() {
return "(" + X + "," + Y + ")";
}
/** This operator determines whether two Points have the same
location.
<p>p1 is the first Point to be compared.
<p>p2 is the second Point to be compared.
<p>True if the Points have the same location and they have
the exact same type; otherwise, false.
@see Equals
*/
public static boolean equals(Point p1, Point p2) {
if ((Object)p1 == null || (Object)p2 == null) {
return false;
}
if (p1.getClass() == p2.getClass()) {
return (p1.X == p2.X) && (p1.Y == p2.Y);
}
return false;
}
/** This operator determines whether two Points have the same
location.
<p>p1 is the first Point to be compared.
<p>p2 is the second Point to be compared.
<p>True if the Points do not have the same location and the
exact same type; otherwise, false.
@see locationEquals
*/
public static boolean notEquals(Point p1, Point p2) {
return !(p1 == p2);
}
/** This is the entry point of the Point class testing
program.
<p>This program tests each method and operator, and
is intended to be run after any non-trvial maintenance has
been performed on the Point class.
*/
public static void main(String[] args) {
// class test code goes here
}
}
use javadoc tool to
generate Java API format
|
|
C# |
single-line-comment:
// input-characters
multiple-line-comment:
/* .... */
/// documetation */
XML format
namespace Graphics
{
/// <remarks>Class <c>Point</c> models a point in a two-dimensional plane.
/// </remarks>
public class Point
{
/// <summary>Instance variable <c>x</c> represents the point's
/// x-coordinate.</summary>
private int x;
/// <summary>Instance variable <c>y</c> represents the point's
/// y-coordinate.</summary>
private int y;
/// <value>Property <c>X</c> represents the point's x-coordinate.</value>
public int X
{
get { return x; }
set { x = value; }
}
/// <value>Property <c>Y</c> represents the point's y-coordinate.</value>
public int Y
{
get { return y; }
set { y = value; }
}
/// <summary>This constructor initializes the new Point to
/// (0,0).</summary>
public Point() : this(0,0) {}
/// <summary>This constructor initializes the new Point to
/// (<paramref name="xor"/>,<paramref name="yor"/>).</summary>
/// <param><c>xor</c> is the new Point's x-coordinate.</param>
/// <param><c>yor</c> is the new Point's y-coordinate.</param>
public Point(int xor, int yor) {
X = xor;
Y = yor;
}
/// <summary>This method changes the point's location to
/// the given coordinates.</summary>
/// <param><c>xor</c> is the new x-coordinate.</param>
/// <param><c>yor</c> is the new y-coordinate.</param>
/// <see cref="Translate"/>
public void Move(int xor, int yor) {
X = xor;
Y = yor;
}
/// <summary>This method changes the point's location by
/// the given x- and y-offsets.
/// <example>For example:
/// <code>
/// Point p = new Point(3,5);
/// p.Translate(-1,3);
/// </code>
/// results in <c>p</c>'s having the value (2,8).
/// </example>
/// </summary>
/// <param><c>xor</c> is the relative x-offset.</param>
/// <param><c>yor</c> is the relative y-offset.</param>
/// <see cref="Move"/>
public void Translate(int xor, int yor) {
X += xor;
Y += yor;
}
/// <summary>This method determines whether two Points have the same
/// location.</summary>
/// <param><c>o</c> is the object to be compared to the current object.
/// </param>
/// <returns>True if the Points have the same location and they have
/// the exact same type; otherwise, false.</returns>
/// <seealso cref="operator=="/>
/// <seealso cref="operator!="/>
public override bool Equals(object o) {
if (o == null) {
return false;
}
if (this == o) {
return true;
}
if (GetType() == o.GetType()) {
Point p = (Point)o;
return (X == p.X) && (Y == p.Y);
}
return false;
}
/// <summary>Report a point's location as a string.</summary>
/// <returns>A string representing a point's location, in the form (x,y),
/// without any leading, training, or embedded whitespace.</returns>
public override string ToString() {
return "(" + X + "," + Y + ")";
}
/// <summary>This operator determines whether two Points have the same
/// location.</summary>
/// <param><c>p1</c> is the first Point to be compared.</param>
/// <param><c>p2</c> is the second Point to be compared.</param>
/// vreturns>True if the Points have the same location and they have
/// the exact same type; otherwise, false.</returns>
/// <seealso cref="Equals"/>
/// <seealso cref="operator!="/>
public static bool operator==(Point p1, Point p2) {
if ((object)p1 == null || (object)p2 == null) {
return false;
}
if (p1.GetType() == p2.GetType()) {
return (p1.X == p2.X) && (p1.Y == p2.Y);
}
return false;
}
/// <summary>This operator determines whether two Points have the same
/// location.</summary>
/// <param><c>p1</c> is the first Point to be compared.</param>
/// <param><c>p2</c> is the second Point to be compared.</param>
/// <returns>True if the Points do not have the same location and the
/// exact same type; otherwise, false.</returns>
/// <seealso cref="Equals"/>
/// <seealso cref="operator=="/>
public static bool operator!=(Point p1, Point p2) {
return !(p1 == p2);
}
/// <summary>This is the entry point of the Point class testing
/// program.
/// <para>This program tests each method and operator, and
/// is intended to be run after any non-trvial maintenance has
/// been performed on the Point class.</para></summary>
public static void Main() {
// class test code goes here
}
}
}
>csc Point.cs /doc:my.xml
<doc>
<assembly>
<name>Point</name>
</assembly>
<members>
<member name="T:Graphics.Point">
<remarks>Class <c>Point</c> models a point in a two-dimensional
plane.
</remarks>
</member>
<member name="F:Graphics.Point.x">
<summary>Instance variable <c>x</c> represents the point's
x-coordinate.</summary>
</member>
<member name="F:Graphics.Point.y">
<summary>Instance variable <c>y</c> represents the point's
y-coordinate.</summary>
</member>
<member name="M:Graphics.Point.#ctor">
<summary>This constructor initializes the new Point to
(0,0).</summary>
</member>
<member name="M:Graphics.Point.#ctor(System.Int32,System.Int32)">
<summary>This constructor initializes the new Point to
(<paramref name="xor"/>,<paramref name="yor"/>).</summary>
<param><c>xor</c> is the new Point's x-coordinate.</param>
<param><c>yor</c> is the new Point's y-coordinate.</param>
</member>
<member name="M:Graphics.Point.Move(System.Int32,System.Int32)">
<summary>This method changes the point's location to
the given coordinates.</summary>
<param><c>xor</c> is the new x-coordinate.</param>
<param><c>yor</c> is the new y-coordinate.</param>
<see cref="M:Graphics.Point.Translate(System.Int32,System.Int32)"/>
</member>
<member
name="M:Graphics.Point.Translate(System.Int32,System.Int32)">
<summary>This method changes the point's location by
the given x- and y-offsets.
<example>For example:
<code>
Point p = new Point(3,5);
p.Translate(-1,3);
</code>
results in <c>p</c>'s having the value (2,8).
</example>
</summary>
<param><c>xor</c> is the relative x-offset.</param>
<param><c>yor</c> is the relative y-offset.</param>
<see cref="M:Graphics.Point.Move(System.Int32,System.Int32)"/>
</member>
<member name="M:Graphics.Point.Equals(System.Object)">
<summary>This method determines whether two Points have the same
location.</summary>
<param><c>o</c> is the object to be compared to the current
object.
</param>
<returns>True if the Points have the same location and they have
the exact same type; otherwise, false.</returns>
<seealso
cref="M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)"/>
<seealso
cref="M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)"/>
</member>
<member name="M:Graphics.Point.ToString">
<summary>Report a point's location as a string.</summary>
<returns>A string representing a point's location, in the form
(x,y),
without any leading, training, or embedded whitespace.</returns>
</member>
<member
name="M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)">
<summary>This operator determines whether two Points have the
same
location.</summary>
<param><c>p1</c> is the first Point to be compared.</param>
<param><c>p2</c> is the second Point to be compared.</param>
<returns>True if the Points have the same location and they have
the exact same type; otherwise, false.</returns>
<seealso cref="M:Graphics.Point.Equals(System.Object)"/>
<seealso
cref="M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)"/>
</member>
<member
name="M:Graphics.Point.op_Inequality(Graphics.Point,Graphics.Point)">
<summary>This operator determines whether two Points have the
same
location.</summary>
<param><c>p1</c> is the first Point to be compared.</param>
<param><c>p2</c> is the second Point to be compared.</param>
<returns>True if the Points do not have the same location and
the
exact same type; otherwise, false.</returns>
<seealso cref="M:Graphics.Point.Equals(System.Object)"/>
<seealso
cref="M:Graphics.Point.op_Equality(Graphics.Point,Graphics.Point)"/>
</member>
<member name="M:Graphics.Point.Main">
<summary>This is the entry point of the Point class testing
program.
<para>This program tests each method and operator, and
is intended to be run after any non-trvial maintenance has
been performed on the Point class.</para></summary>
</member>
<member name="P:Graphics.Point.X">
<value>Property <c>X</c> represents the point's
x-coordinate.</value>
</member>
<member name="P:Graphics.Point.Y">
<value>Property <c>Y</c> represents the point's
y-coordinate.</value>
</member>
</members>
</doc>
|
|