我正在尝试修改代码,但得到标题中列出的错误。请帮助。
错误:BruteCollinearPoints 类型中的方法 segments() 不适用于参数 (Point, Point)
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import edu.princeton.cs.algs4.*;
public class BruteCollinearPoints
{
public BruteCollinearPoints(Point[] points) // finds all line segments containing 4 points
{
int N = points.length;
int i = 0;
for (int p = 0; p < N; p++) {
for (int q = p + 1; q < N; q++) {
double slopeToQ = points[p].slopeTo(points[q]);
for (int r = q + 1; r < N; r++) {
double slopeToR = points[p].slopeTo(points[r]);
if (slopeToQ == slopeToR) {
for (int s = r + 1; s < N; s++) {
double slopeToS = points[p].slopeTo(points[s]);
if (slopeToQ == slopeToS) {
// Create the list of collinear points and sort them.
List<Point> collinearPoints = new ArrayList<Point>(4);
collinearPoints.add(points[p]);
collinearPoints.add(points[q]);
collinearPoints.add(points[r]);
collinearPoints.add(points[s]);
Collections.sort(collinearPoints);
segments(Collections.min(collinearPoints), Collections.max(collinearPoints)); //this is where the error is
}
}
}
}
}
}
}
//public int numberOfSegments(); // the number of line segments
public LineSegment[] segments() // the line segments
{
return segments();
}
}