forked from next-step/java-coordinate-playground
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStraight.java
More file actions
27 lines (23 loc) · 845 Bytes
/
Straight.java
File metadata and controls
27 lines (23 loc) · 845 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
package coordinate;
public class Straight implements Coordinate {
private final double x1;
private final double x2;
private final double y1;
private final double y2;
private final double sqrt;
public Straight(String[] split) {
this.x1 = Double.parseDouble(split[0]);
this.y1 = Double.parseDouble(split[1]);
this.x2 = Double.parseDouble(split[2]);
this.y2 = Double.parseDouble(split[3]);
this.sqrt = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
public double getSqrt() {
return this.sqrt;
}
@Override
public void printSpecialCharacter() {
System.out.println("좌표는(" + this.x1 +"," + this.y1 + ")-(" + this.x2 + "," + this.y2 + ")입니다." );
System.out.println("두점 사이의 거리는" + this.sqrt);
}
}