title: Trouble finding calling two points to one method. "Java - distancePoint"
body: <p>I am trying to understand why I am having a difficult time calling two different points into a method in order to determine the distance between the two points.</p>
  
  <p>This is the text provided on the website "Practice-It", where I am currently working through problems:</p>
  
  <hr>
  
  <p>Add the following method to the Point class:</p>
  
  <p>public double distance(Point other)</p>
  
  <p>Returns the distance between the current Point object and the given other Point object. The distance between two points is equal to the square root of the sum of the squares of the differences of their x- and y-coordinates. In other words, the distance between two points (x1, y1) and (x2, y2) can be expressed as the square root of (x2 - x1)2 + (y2 - y1)2. Two points with the same (x, y) coordinates should return a distance of 0.0."</p>
  
  <hr>
  
  <p>I have tried multiple ways to get the points into the method without naming individual coordinates.  I believe that I am only getting the coordinates of the first point and am trying to understand where I am going wrong as I've had this problem before.  I realize that the "int x1 = p1.x", etc. is redundant and I could just type "p1.x" in the return, but I am wanting to see all of the moving parts individually.  Thanks for your consideration and help.</p>
  
  <pre><code>public double distance(Point other){
      Point p1 = new Point();
      int x1 = p1.x;
      int y1 = p1.y;
      Point p2 = new Point();
      int x2 = p2.x;
      int y2 = p2.y;
  
      return Math.sqrt(Math.pow(x * x2, 2) + Math.pow(y * y2, 2));
  }
  </code></pre>
  
  <p>This is my result from one of the situations tested:</p>
  
  <pre><code>test #1:(5, 2) to (8, 6)
  expected output:
  5.0
  5.0
  your output:
  0.0
  0.0
  differences:
  1,2c1,2
  &lt; 5.0
  &lt; 5.0
  &gt; 0.0
  &gt; 0.0
  result: fail
  </code></pre>