title: Class method troubles - Python
body: <p>So having some trouble with a class methods. I'll post all the information that I have. I need to write the relevant methods for the questions given.</p>
  
  <pre><code>import math
  epsilon = 0.000001
  class Point(object):
      def __init__(self, x, y):
          self._x = x
          self._y = y
  
      def __repr__(self):
          return "Point({0}, {1})".format(self._x, self._y)
  </code></pre>
  
  <p>First question; i need to add a method, called disttopoint that takes another point object, p, as an argument and returns the euclidean distance between the two points. I can use math.sqrt.</p>
  
  <p>test cases:</p>
  
  <pre><code>abc = Point(1,2)
  efg = Point(3,4)
  abc.disttopoint(efg) ===&gt; 2.8284271
  </code></pre>
  
  <p>Second question; add a method, called isnear that takes another point object, p, as an argument and returns True if the distance between this point and p is less than epsilon (defined in the class skeleton above) and False otherwise. Use disttopoint. </p>
  
  <p>test cases:</p>
  
  <pre><code>abc = Point(1,2)
  efg = Point(1.00000000001, 2.0000000001)
  abc.isnear(efg) ===&gt; True
  </code></pre>
  
  <p>Third question; add a method called addpoint that takes another point object p as an arguement and changes this point so that it is the sum of the oint's old value and the value of p.</p>
  
  <p>test cases; </p>
  
  <pre><code>abc = Point(1,2)
  efg = Point(3,4)
  abc.add_point(bar)
  repr(abc) ==&gt; "Point(4,6)
  </code></pre>