-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMerkleManager.java
46 lines (33 loc) · 1.47 KB
/
MerkleManager.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
public class MerkleManager {
public static volatile String userEnteredWord; //value of variable must never be cached
public static String expectedMerkleRoot;
public static String actualMerkleRoot = null;
public static int iStrikes = 0;
public void manage() {
Util util1 = new Util();
//reference website
//https://www.w3resource.com/java-tutorial/java-defining-instantiating-and-starting-threads.php
//instantiate
MerkleThread instanceMerkle = new MerkleThread();
RogueThread instanceRogue = new RogueThread();
MonitorThread instanceMonitor = new MonitorThread();
// new threads
Thread merkleThread = new Thread(instanceMerkle);
Thread rogueThread = new Thread(instanceRogue);
Thread monitorThread = new Thread(instanceMonitor);
merkleThread.start();
rogueThread.start();
monitorThread.start();
String sQuestion0 = "Enter expected merkle root (use https://xorbin.com/tools/sha256-hash-calculator): ";
expectedMerkleRoot = util1.promptUser(sQuestion0);
while (true) {
MerkleManager.userEnteredWord = util1.promptUser("Enter the word: "); //need prompt user method in Util
}
}
public static synchronized String grabWord() {
String temp = userEnteredWord;
userEnteredWord = null; //means user entered word is set to string
// temp which == null
return temp; //returns string
}
}