forked from hegenova/Quiz_3_Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWords2SigProto.java
More file actions
34 lines (29 loc) · 1.03 KB
/
Copy pathWords2SigProto.java
File metadata and controls
34 lines (29 loc) · 1.03 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
//package predictive;
import java.util.*;
//The command line program Words2SigProto will make use of the wordToSignature method from PredictivePrototype.
//The String[] args array will store all input.
//If the array is empty, it will use a scanner to read the user input at runtime and add it to the recently made list.
//If the array is not empty / has an input, it will create a new list with that new input in it.
//If the new list is not empty, it will use the wordToSignature method and print out the result.
public class Words2SigProto {
public static void main(String[]args) {
ArrayList<String> list;
new PredictivePrototype();
if (args.length == 0) {
list = new ArrayList<String>();
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
list.add(scan.next());
}
scan.close();
}
else {
list = new ArrayList<String>(Arrays.asList(args));
}
if (list.isEmpty()==false) {
for (String s: list) {
System.out.println(s + " : " + PredictivePrototype.wordToSignature(s));
}
}
}
}