A Java Class
class Point
{
public double x, y;
public static Point origin = new
Point(0,0);
Point(double x_value, double y_value)
{
x = x_value;
y = y_value;
}
public void clear()
{
this.x = 0;
this.y = 0;
}
public double distance(Point that)
{
double xDiff = x - that.x;
double yDiff = y - that.y;
return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
}
}
No comments:
Post a Comment