forked from RameshMF/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (30 loc) · 1.48 KB
/
Main.java
File metadata and controls
39 lines (30 loc) · 1.48 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
package modern.challenge;
import java.time.Duration;
import java.time.Instant;
import modern.challenge.ChessClock.Player;
public class Main {
public static void main(String[] args) throws InterruptedException {
ChessClock chessClock = new ChessClock(Player.LEFT);
Instant start = chessClock.gameStart();
System.out.println("Game started:" + start);
Thread.sleep(2000);
System.out.println("\nLeft moved first after 2 seconds: " + chessClock.instant());
Thread.sleep(5000);
System.out.println("Right moved after 5 seconds: " + chessClock.instant());
Thread.sleep(6000);
System.out.println("\nLeft moved after 6 seconds: " + chessClock.instant());
Thread.sleep(1000);
System.out.println("Right moved after 1 second: " + chessClock.instant());
Thread.sleep(2000);
System.out.println("\nLeft moved after 2 second: " + chessClock.instant());
Thread.sleep(3000);
System.out.println("Right moved after 3 seconds: " + chessClock.instant());
Thread.sleep(10000);
System.out.println("\nLeft moved after 10 seconds: " + chessClock.instant());
Thread.sleep(11000);
System.out.println("Right moved after 11 seconds and win: " + chessClock.instant());
Instant end = chessClock.gameEnd();
System.out.println("\nGame ended:" + end);
System.out.println("\n Game duration: " + Duration.between(start, end).getSeconds() + " seconds");
}
}