-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestPunto.java
49 lines (43 loc) · 1.39 KB
/
TestPunto.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
package prg.es1;
import java.util.InputMismatchException;
import java.util.Scanner;
public class TestPunto{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("PRIMO PUNTO:");
Punto p1 = new Punto();
try{
System.out.print("Inserisci coordinata X: ");
p1.setX(input.nextDouble());
} catch (InputMismatchException exp){
System.out.println("Dato inserito non valido");
input = new Scanner(System.in);
}
try{
System.out.print("Inserisci coordinata Y: ");
p1.setY(input.nextDouble());
} catch (InputMismatchException exp){
System.out.println("Dato inserito non valido");
input = new Scanner(System.in);
}
System.out.println("SECONDO PUNTO:");
Punto p2 = new Punto();
try{
System.out.print("Inserisci coordinata X: ");
p2.setX(input.nextDouble());
} catch (InputMismatchException exp){
System.out.println("Dato inserito non valido");
input = new Scanner(System.in);
}
try{
System.out.print("Inserisci coordinata Y: ");
p2.setY(input.nextDouble());
} catch (InputMismatchException exp){
System.out.println("Dato inserito non valido");
input = new Scanner(System.in);
}
System.out.println("Distance: " + p1.distance(p2));
System.out.println("Middle Point: " + p1.middlePoint(p2).toString());
System.out.println("Equals: " + p1.equals(p2));
}
}