Overloading Method
We could use one method to call another method inside that. We already have distanceTo()
method, we could use another distanceTo()
method with different input and process inside.
public int distanceTo(int x, int y)
{
int xDiffSquared = (X - x) * (X - x);
int yDiffSquared = (Y - y) * (Y - y);
return (int)Math.Sqrt(xDiffSquared + yDiffSquared);
}
public int distanceTo(Point point)
{
return distanceTo(point.X, point.Y);
}