-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMandelbrotMain.java
More file actions
94 lines (77 loc) · 2.26 KB
/
MandelbrotMain.java
File metadata and controls
94 lines (77 loc) · 2.26 KB
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
package mandelbrotSet;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.concurrent.ExecutionException;
public class MandelbrotMain {
public static void main(String[] args) throws InterruptedException, ExecutionException, IOException {
boolean computeType = vidOrPic();
if (computeType) {
picture();
} else {
video();
}
}
private static boolean vidOrPic() {
int input = -1;
while (input == -1) {
System.out.println("Press 1 for picture and 2 for a video.");
input = scanInt();
}
if (input != 1 && input != 2) {
return vidOrPic();
} else if (input == 1) {
return true;
} else {
return false;
}
}
private static void picture() throws InterruptedException, ExecutionException, IOException {
int height = 0;
int max = 0;
while (height <= 0) {
System.out.println(
"Enter the height of the image. Must be positive integer. Image will be 16x9 aspect ratio.");
height = scanInt();
}
while (max <= 0) {
System.out.println("Enter max iterations to run to. Must be positive integer.");
max = scanInt();
}
long start = System.nanoTime();
MakePicture set = new MakePicture(height, max);
set.start();
System.out.println((System.nanoTime() - start) / 1000000000 + " seconds");
}
private static void video() throws IOException, InterruptedException, ExecutionException {
int height = 0;
int max = 0;
int time = 0;
while (height <= 0) {
System.out.println(
"Enter the height of the image. Must be positive integer. Image will be 16x9 aspect ratio.");
height = scanInt();
}
while (max <= 0) {
System.out.println("Enter max iterations to run to. Must be positive integer.");
max = scanInt();
}
while (time <= 0) {
System.out.println("Enter length of the video in seconds. Must be positive integer.");
time = scanInt();
}
long start = System.nanoTime();
MakeVideo set = new MakeVideo(height, max, time);
set.start();
System.out.println((System.nanoTime() - start) / 1000000000 + " seconds");
}
private static int scanInt() {
Scanner scan1 = new Scanner(System.in);
try {
return scan1.nextInt();
} catch (InputMismatchException e) {
System.err.println("Input must be an integer.");
return -1;
}
}
}