-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaunch.java
More file actions
69 lines (51 loc) · 1.61 KB
/
Launch.java
File metadata and controls
69 lines (51 loc) · 1.61 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
package threadsAndDrawingTests;
import java.awt.EventQueue;
import java.util.Scanner;
import threadsAndDrawingTests.frame.*;
public class Launch {
private static DrawingFrame frame = null;
static int answer = 0;
public static void main(String[] args) {
boolean debug = false; // set this to true if you do not want to see the dialogs when program is started
int debugInputValue = 3; // and set the value you want the program to select when you run in
// debug mode and it will chose it bypassing the dialogs
Scanner scanner = new Scanner(System.in);
if (debug) {
processUserInput(debugInputValue);
return;
}
do {
System.out.println("Please select a choise: ");
System.out.println("\t 1: for launching DrawingTest with one color");
System.out.println("\t 2: for launching DrawingTest with two colors");
System.out.println("\t 3: for launching DrawingTest with multiple colors");
while(!scanner.hasNextInt()) {
System.out.println("Please select correct integer value");
scanner.next();
}
answer = scanner.nextInt();
} while (!processUserInput(answer));
scanner.close();
}
private static boolean processUserInput(int choice) {
boolean result = false;
switch (choice) {
case 1:
frame = new DrawingFrameOneColor();
result = true;
break;
case 2:
frame = new DrawingFrameTwoColors();
result = true;
break;
case 3:
frame = new DrawingFrameManyColors();
result = true;
break;
default:
result = false;
break;
}
return result;
}
}