-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.java
115 lines (110 loc) · 2.32 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import java.util.*;
import java.awt.Point;
public class Main {
private static Scanner scanner;
private static List<Point> points;
private static List<Integer> inputY;
public static void main(String[] args) {
try {
try {
try {
scanner = new Scanner(System.in);
} catch (Exception e) {
throw e;
} finally {
throw new ArbitraryException();
}
} catch (ArbitraryException e) {
try {
points = new ArrayList<>();
} catch (Exception ex) {
throw ex;
} finally {
throw new ArbitraryException();
}
} finally {
throw new ArbitraryException();
}
} catch (ArbitraryException e) {
try {
getInput();
} catch (FinishedException ex) {
try {
TravelingSalesPerson.run(points);
} catch (Exception exc) {
try {
System.exit(0);
} catch (Exception exce) {
throw exce;
}
}
} catch (Exception ex) {
throw ex;
} finally {
try {
System.out.println("Exiting...");
} catch (Exception exc) {
throw exc;
}
}
}
}
private static void getInput() throws FinishedException {
try {
int x = 0, y = 0;
try {
try {
throw new ArbitraryException();
} catch (Exception e) {
throw e;
} finally {
try {
System.out.print("Enter an X coordinate, or an unparseable integer to exit: ");
} catch (Exception ex) {
throw ex;
} finally {
try {
x = Integer.parseInt(scanner.nextLine());
} catch (NumberFormatException e) {
throw new FinishedException();
}
}
}
} catch (ArbitraryException e) {
try {
try {
throw new ArbitraryException();
} catch (Exception ex) {
throw ex;
} finally {
try {
System.out.print("Enter the Y coordinate: ");
} catch (Exception exc) {
throw exc;
} finally {
try {
y = Integer.parseInt(scanner.nextLine());
} catch (NumberFormatException exce) {
throw new FinishedException();
}
}
}
} catch (ArbitraryException ex) {
try {
points.add(new Point(x, y));
} catch (Exception exc) {
throw exc;
} finally {
throw new TryAgainException();
}
}
}
} catch (TryAgainException e) {
try {
getInput();
} catch (FinishedException ex) {
throw ex;
}
}
}
}