-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessages.java
More file actions
43 lines (33 loc) · 901 Bytes
/
Messages.java
File metadata and controls
43 lines (33 loc) · 901 Bytes
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
package blockchain;
import java.util.List;
import java.util.Scanner;
public class Messages implements Runnable {
private final List<Message> MESSAGE_LIST;
private final Scanner sc;
private boolean stop;
Messages(List<Message> messageList) {
this.MESSAGE_LIST = messageList;
this.sc = new Scanner(System.in);
}
@Override
public void run() {
while (!stop) {
this.MESSAGE_LIST.add(new Message(sc.next(), sc.nextLine()));
}
}
public void stop() {
System.out.println("was called");
this.stop = true;
}
}
class Message {
private final String NAME;
private final String CONTENT;
Message(String name, String content) {
this.NAME = name;
this.CONTENT = content;
}
public String toString() {
return String.format("%s: %s", this.NAME, this.CONTENT);
}
}