-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
65 lines (52 loc) · 1.16 KB
/
Main.java
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package beginner.ex1015;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
UserInterface userInterface = new UserInterface();
userInterface.input();
userInterface.print();
}
}
class UserInterface
{
private Scanner input;
private Plane plane;
public UserInterface()
{
input = new Scanner(System.in);
plane = new Plane();
}
public void input()
{
plane.setX1(input.nextDouble());
plane.setY1(input.nextDouble());
plane.setX2(input.nextDouble());
plane.setY2(input.nextDouble());
}
public void print()
{
System.out.printf("%.4f%n", plane.distanceBetweenPoints());
}
}
class Plane
{
private double x1, x2, y1, y2;
public void setX1(double x1) {
this.x1 = x1;
}
public void setX2(double x2) {
this.x2 = x2;
}
public void setY1(double y1) {
this.y1 = y1;
}
public void setY2(double y2) {
this.y2 = y2;
}
public double distanceBetweenPoints()
{
return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
}
}