Given points on a 2D plane, find line that passes through the most points Could someone give some feedbacks from perspective of oo design and coding style on the following codes:

Question: Given n points on a 2D plane, find the Line with maximum number of points that lie on it. Similar to https://leetcode.com/problems/max-points-on-a-line/description/. I was given Point interface, empty Line class, empty Solution class and was asked to fill in some functions.

My codes:

public interface Point
{
  public double getX();
  public double getY();
}

public class Line
{ // added by myself.
  private Point p1, p2;
  public Line(Point p1, Point p2) {
    this.p1 = p1;
    this.p2 = p2;
  }
}


public class Solution
{
  // Write the function here
  public Line maxPointsLine(Point[] points) {
    if(points == null) return null;
    if(points.length==1) return new Line(points[0], new Point(p));//
    Map&lt;Double, Integer&gt; map = new HashMap&lt;&gt;();// O(n), n = points.length. n-1
    Line result;
    int maxPoints = 0;
    for(int i = 0; i &lt; points.length; i++) { // One Point
      map.clear();
      int overlap =0;
      int countSameX = 1;
      for(int j = i+1; j &lt; points.length; j++) { // the second Point
        double x = points[j].getX() - points[i].getX(); // x intersect
        double y = points[j].getY() - points[i].getY(); // intersect on y coordinate

        if(x==0 &amp;&amp; y==0) {
          overlap++;
        }
        if(points[j].getX()==points[i].getX()) {// slope is infi,
          // slope (1) finite, (2) infinite,
          countSameX++;
          continue;
        }
        double slope = y/x;
        if(map.contains(slope)) map.put(slope, map.get(slope)+1);
        else map.put(slope, 2);
        if(map.get(slope)+overlap &gt; maxPoints) { // each line slope and points[i]
          // update result and maxPoints
          maxPoints = map.get(slope)+overlap;
          result = new Line(points[i], points[j]);
        }
      }
      if(countSameX&gt;maxPoints) { // line parallel to Y coordinate
        // update result and maxPoints
        maxPoints = countSameX;
        result = new Line(points[i], points[j]);
      }
    }
    return result;// null
  }
}


In the above codes, I added some comments based on questions I was asked.

(I did this coding question long ago. just came into my mind. ) In fact, the interviewer told me that didn’t have good coding style and lack of OO design. suggestions are welcomed for me to improve myself. Thanks.

By the way, as for coding style, there are plugins following standards like https://google.github.io/styleguide/javaguide.html. I just did not fix coding style issues manually due to lack of time. 

As for OO design, I was given empty classes. I just added some functions to solve problem I was given.

I really did not find any big issues in my codes. Confused and frustrated.
i think your task was to use the given classes Point and Lineand extend them...

public class Line{

    public Line (Point a, Point b);

    public boolean contains(Point p);

}


thus leaving a quite simple task in your Solution (and pretty easy to read)

Lines lines = getAllLines();//easily iterate over the permutated Point matrix

for(Line line: lines){
    int amountOfPoints = 0;
    for (Point p: points){
        if (line.contains(p) {
            amountOfPoint = amountOfPoint + 1;
    }       
}


NOTE

this is just an explanation of OO-Programming, i didn't include the subtaks, e.g. how to get the max of the lines, or how contains() works, but it surely gives a hint on where the questions aims at...