public class Line
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private double |
slope
A
double value specifying the slope of the line. |
private double |
yIntercept
A
double value specifying the y intercept of the line. |
| Constructor and Description |
|---|
Line(double slope,
double yIntercept)
Constructor that accepts the slope and y intercept of the line.
|
Line(Point p1,
Point p2)
Constructor that accepts two
Points specifying a line
segment on the line. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object object)
Method to compare 'this' line for equality with the 'object'
specified as a parameter.
|
double |
getSlope()
A getter for the slope of the line.
|
double |
getyIntercept()
A getter for the y intercept of the line.
|
Point |
intersection(Line line)
A method that computes and returns the Point intersection of 'this' line and
the line specified in the parameter.
|
boolean |
isParallelTo(Line line)
This method tests 'this' line and the 'line' specified as a parameter
for being parallel.
|
boolean |
isPerpendicularTo(Line line)
This method tests 'this' line and the 'line' specified as a parameter
for being perpendicular.
|
boolean |
pointIsOnTheLine(Point p)
This method is called to find if the specified Point lies on 'this' line.
|
void |
setSlope(double slope)
A setter for the slope of the line.
|
void |
setyIntercept(double yIntercept)
A setter for the y intercept of the line.
|
java.lang.String |
toString()
Method to render 'this' instance of the Line class into a String.
|
void |
updateLine(Point p1,
Point p2)
This method accepts two
Points specifying a line
segment on the line. |
private double slope
double value specifying the slope of the line.private double yIntercept
double value specifying the y intercept of the line.public Line(double slope,
double yIntercept)
slope - A double value specifying the slope of the line.yIntercept - A double value specifying the y intercept of the line.public Line(Point p1, Point p2)
Points specifying a line
segment on the line. Using these two Points, both the
slope and the y intercept may be calculated by the constructor.p1 - A Point specifying the first endpoint of the line segmentp2 - A Point specifying the second endpoint of the line segmentpublic void updateLine(Point p1, Point p2)
Points specifying a line
segment on the line. This method is called to update the
Line when the two points identifying the subclass
LineSegment, change. This method will recompute the
slope and the y intercept.p1 - A Point specifying the first endpoint of the line segmentp2 - A Point specifying the second endpoint of the line segmentpublic double getSlope()
public void setSlope(double slope)
slope - A double value representing a new slope for the line.public double getyIntercept()
public void setyIntercept(double yIntercept)
yIntercept - A double value representing a new slope for the line.public boolean isParallelTo(Line line)
line - The Line we are testing for being parallel to 'This' line.public boolean isPerpendicularTo(Line line)
line - The Line we are testing for being perpendicular to 'This' line.public Point intersection(Line line)
line - The line for which we are computing the intersection with 'this'
line.public boolean pointIsOnTheLine(Point p)
p - The point we are checking to see if it lies on the 'this' line.public boolean equals(java.lang.Object object)
equals in class java.lang.Objectobject - An Object to be tested for equality with 'this' linepublic java.lang.String toString()
toString in class java.lang.Object