X hits on this document

1041 views

0 shares

362 / 396

/// <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 + ")"; }