title: Maximum Disc Coverage
body: <p>We are supposed to find with every point (distance between two points must be &lt;= 2) forming a circle, what is the maximum number of points that can be contained by a circle formed by these points. These points are stored in list. It just means among the list of points, we are supposed to pair two points together and see whether a circle forms by this 2 points can contain the most number of points. We are finding the most number of points.</p>
  <p>Here is the code.</p>
  <pre><code>class Point {
      private final double x;
      private final double y;
  
      Point (double x, double y) {
          this.x = x;
          this.y = y;
      }
  
      Point midPoint(Point q) {
          Point midPoint = new Point ((this.x + q.x)/2, (this.y + q.y)/2);
          return midPoint;
      }
  
      double distanceTo (Point q) {     
          return Math.sqrt(Math.pow((this.x - q.x), 2) + Math.pow((this.y - q.y),2));
  
      }
  
      double angleTo(Point q) {
          Point middlePoint = midPoint(q);
          return Math.atan2(middlePoint.x, middlePoint.y);
      }
  
      Point moveTo(double theta, double d) {
          Point newPoint = new Point ((this.x + d * Math.cos(theta)), this.y + d * Math.sin(theta));
          return newPoint;
      }
  
      @Override
      public String toString () {
         return &quot;point (&quot; +  String.format(&quot;%.3f&quot;,this.x) + &quot;, &quot; + String.format(&quot;%.3f&quot;, this.y) + &quot;)&quot;; 
      }
  
  }
  </code></pre>
  <pre><code>import java.util.List;
  
  class Circle {
      private final Point centre;
      private final double radius;
  
      Circle (Point centre, double radius) {
          this.centre = centre;
          this.radius = radius;
      }
      
      public int containsPoints (List&lt;Point&gt; points) {
          int numOfPoints = 0;
          for (int i = 0; i&lt; points.size(); i++) {
              if (centre.distanceTo(points.get(i)) &lt;= 2) {
                  numOfPoints++;
              }
          }
          return numOfPoints;
      }
  
  
      @Override
      public String toString() {
          return &quot;circle of radius &quot; + this.radius + &quot; centered at &quot; + this.centre;
      }
  
  }
  </code></pre>
  <pre><code>import java.util.List;
  
  Circle createUnitCircle(Point p, Point q) {
      double anglePQ = p.angleTo(q);
      Point midPoint = p.midPoint (q);
      double pqDistance = p.distanceTo(q);
      double mqDistance = midPoint.distanceTo(q);
      double dSquare = 1 - Math.pow(mqDistance, 2);
      double d = Math.sqrt (dSquare);
  
      Point centre = midPoint.moveTo(anglePQ, d);
      return new Circle (centre, 1);
  }
  
  int findMaxDiscCoverage (List&lt;Point&gt; points) {
      int maxDiscCoverage = 0;
      int numOfPoints = points.size();
      int numOfPointsContained = 0; 
       
      for (int i = 0; i &lt; numOfPoints - 1; i++) {
          for (int j = i + 1; j &lt; numOfPoints; j++) {
              Point point1 = points.get(i);
              Point point2 = points.get(j);
              if (point1.distanceTo(point2) &gt; 2) {
                  continue;
              }
             Circle c1 = createUnitCircle(point1, point2);
             numOfPointsContained = c1.containsPoints(points);
             if (numOfPointsContained &gt; maxDiscCoverage) {
                 maxDiscCoverage = numOfPointsContained;
             }
      return maxDiscCoverage;
  }
  </code></pre>
  <p>I keep getting error like this</p>
  <pre><code>|  Error:
  |  cannot find symbol
  |    symbol:   method findMaxDiscCoverage(java.util.List&lt;Point&gt;)
  |  findMaxDiscCoverage(points)
  |  ^-----------------^
  
  </code></pre>
  <p>Please help me! Thank you!</p>