-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLine.java
More file actions
44 lines (34 loc) · 887 Bytes
/
Line.java
File metadata and controls
44 lines (34 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.example;
public class Line {
Point begin;
Point end;
public Line(Point begin, Point end) {
this.begin = begin;
this.end = end;
}
public Point getBegin() {
return begin;
}
public void setBegin(Point begin) {
this.begin = begin;
}
public Point getEnd() {
return end;
}
public void setEnd(Point end) {
this.end = end;
}
public Point[] getLine() {
return new Point[]{begin, end};
}
public void setLine(Point begin, Point end) {
this.begin = begin;
this.end = end;
}
public double getLineLength() {
double tempLine1 = (end.getX() - begin.getX() );
double tempLine2 = (end.getY() - begin.getY() );
double result = Math.sqrt( Math.pow(tempLine1, 2) + Math.pow(tempLine2, 2) );
return result;
}
}