Hello, I have been learning Java just for a few days and right in my first little assignment I got stuck.
Here is the code:
Code:public class Vertex
{
private double x;
private double y;
public void setPt(double x, double y) {
this.x = x;
this.y = y;
}
// Now this method should take another vertex and return their distance. The formula itself is OK.
public double distance(Vertex otherPoint) {
return Math.sqrt(((this.x - otherPoint.x)*(this.x - otherPoint.x)) + ((this.y - otherPoint.y)*(this.y - otherPoint.y)));
}
}
Vertex a = new Vertex();
Vertex b = new Vertex();
a.setPt(1,1);
b.setPt(0,0);
b.distance(a); // This call does not calculate the distance.
System.out.println("Distance is: " + b);
What am I doing wrong?

