public class LineSegment extends Line
A line segment has two endpoints and lies on a line with the same slope. This class is a subclass of the Line class.
| Modifier and Type | Field and Description |
|---|---|
private Point |
p1
Point representing the first endpoint for the line segment
|
private Point |
p2
Point representing the second endpoint for the line segment
|
| Constructor and Description |
|---|
LineSegment(Point p1,
Point p2)
Constructor that accepts the two endpoints of the line segment.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object object)
Method to compare 'this' line segment for equality with the 'object' specified
as a parameter.
|
Point |
getP1()
Getter for the first endpoint
|
Point |
getP2()
Getter for the second endpoint
|
void |
setP1(Point p1)
Setter to change the first endpoint
|
void |
setP2(Point p2)
Setter to change the first endpoint
|
getSlope, getyIntercept, intersection, isParalellTo, isPerpendicularTo, setSlope, setyInterceptprivate Point p1
private Point p2
public LineSegment(Point p1, Point p2)
p1 - Point representing one endpoint of the line segmentp2 - Point representing the other endpoint of the line segmentpublic Point getP1()
public void setP1(Point p1)
p1 - A Point representing the new first enpoint of the line segmentpublic Point getP2()
public void setP2(Point p2)
p1 - A Point representing the new first enpoint of the line segmentpublic boolean equals(java.lang.Object object)