forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInitiator.java
68 lines (60 loc) · 2.26 KB
/
Initiator.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
import java.util.Scanner;
public class Initiator extends Thread {
public static boolean initiator() {
boolean flag = false;
int countdown = 5;
Scanner scan = new Scanner(System.in);
while (flag == false) {
System.out.println("!! Enter 'START' to begin the Quiz !!");
String input = scan.nextLine();
if (input.equals("START")) {
System.out.print("Quiz starting in " + countdown);
while (countdown-- > 0) {
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
}
System.out.print("\b" + countdown);
}
System.out.println("");
flag = true;
return flag;
} else {
System.out.println(
"Please enter 'START' correctly. If you not want to start quiz then just enter 'QUIT'");
String in = scan.next();
if (in.equals("QUIT")) {
System.out.print("EXITING the Quiz");
int i = 2;
while (i-- > 0) {
for (int j = 0; j < 3; j++) {
System.out.print(".");
try {
Thread.sleep(700);
} catch (InterruptedException e) {
}
if (j == 2) {
System.out.print("\b\b\b");
}
}
}
return false;
}
if (in.equals("START")) {
input = "START";
System.out.print("Quiz starting in " + countdown);
while (countdown-- > 0) {
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
}
System.out.print("\b" + countdown);
}
System.out.println("");
return true;
}
}
}
return true;
}
}