|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectclasswork.Line
public class Line
Models a line.
| Field Summary | |
|---|---|
private double |
b
The x-intercept of the line. |
private double |
m
The slope of the line. |
private boolean |
vertical
Whether or not the line is vertical. |
| Constructor Summary | |
|---|---|
Line(double m,
int b)
Constructs a line given a slope and an x-intercept. |
|
Line(int a)
Constructs a line in the form x = a. |
|
Line(int x,
int y,
double m)
Constructs a line given a point and a slope. |
|
Line(int x1,
int y1,
int x2,
int y2)
Constructs a line given two points. |
|
| Method Summary | |
|---|---|
boolean |
equals(Line other)
|
double |
getB()
|
double |
getSlope()
|
boolean |
intersects(Line other)
|
boolean |
isParallel(Line other)
|
boolean |
isVertical()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private double m
private double b
private boolean vertical
| Constructor Detail |
|---|
public Line(int x,
int y,
double m)
x - The x-coordinate.y - The y-coordinate.m - The slope.
public Line(int x1,
int y1,
int x2,
int y2)
x1 - The first x-coordinate.y1 - The first y-coordinate.x2 - The second x-coordinate.y2 - The second y-coordinate.
public Line(double m,
int b)
m - The slope.b - The x-intercept.public Line(int a)
a - The x-intercept of the vertical line.| Method Detail |
|---|
public double getSlope()
public double getB()
public boolean isVertical()
public boolean intersects(Line other)
other - The other line to be tested.
public boolean isParallel(Line other)
other - The other line to be tested.
public boolean equals(Line other)
other - The other line to be tested,
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||