考虑我们有两个类Line
,Point
哪个类 Line 使用Point
如下类:
public class Point {
private int x;
private int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
和
public Class Line
{
private Point start;
private Point end;
...
}
我想知道由于 OOP 原则,下面哪些构造函数更适合 Line 类?
public Line(Point start, Point end)
{
this.start = start;
this.end = end;
}
或者
public Line(int startX, int startY, int endX, int endY)
{
start = new Point(startX, startY);
end = new Point(endX, endY);
}