Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Line {
- private Point start;
- private Point end;
- public Line(double x1, double y1, double x2, double y2) {
- this.start= new Point(x1, y1);
- this.end= new Point(x2, y2);
- }
- public Line(Point p1, Point p2) {
- this.start=new Point(p1);
- this.end=new Point(p2);
- }
- public Line(Line that) {
- this.start=new Point(that.start);
- this.start=new Point(that.end);
- }
- public Point getStart() {
- return start;
- }
- public Point getEnd() {
- return end;
- }
- public double getStartX() {
- return start.getX();
- }
- public double getStartY() {
- return start.getY();
- }
- public double getEndX() {
- return end.getX();
- }
- public double getEndY() {
- return end.getY();
- }
- public void setStart(Point newStart) {
- start=newStart;
- }
- public void setEnd(Point newEnd) {
- end=newEnd;
- }
- public void setEndX(double x) {
- end.setX(x);
- }
- public double length() {
- return Math.sqrt(Math.pow(start.getX()-end.getX(), 2)+
- Math.pow(start.getY()-end.getY(), 2));
- }
- public Point midpoint() {
- return new Point((start.getX()+end.getX())/2,
- (start.getY()+end.getY())/2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement