-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary.java
More file actions
83 lines (60 loc) · 1.77 KB
/
Copy pathDictionary.java
File metadata and controls
83 lines (60 loc) · 1.77 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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Random;
import java.io.File;
import java.io.FileNotFoundException;
class Dictionary{
Dictionary(){
File nounFile = new File("nouns.txt");
try{
Scanner ns = new Scanner(nounFile);
while(ns.hasNextLine()){
NounList.add(ns.nextLine());
}
ns.close();
} catch (FileNotFoundException e){
e.printStackTrace();
}
//fills noun list from txt
File adjFile = new File("adjectives.txt");
try{
Scanner as = new Scanner(adjFile);
while(as.hasNextLine()){
AdjectiveList.add(as.nextLine());
}
as.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//fills adjective list from text file
File prepFile = new File("prepositions.txt");
try{
Scanner ps = new Scanner(prepFile);
while(ps.hasNextLine()){
PrepositionList.add(ps.nextLine());
}
ps.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public String getRandomNoun(){
Random r = new Random();
int n = r.nextInt(NounList.size());
return NounList.get(n);
}
public String getRandomAdjective(){
Random r = new Random();
int n = r.nextInt(AdjectiveList.size());
return AdjectiveList.get(n);
}
public String getRandomPreposition(){
Random r = new Random();
int n = r.nextInt(PrepositionList.size());
return PrepositionList.get(n);
}
private ArrayList<String> NounList = new ArrayList<String>();
private ArrayList<String> AdjectiveList = new ArrayList<String>();
private ArrayList<String> RelPronounList = new ArrayList<String>();
private ArrayList<String> PrepositionList = new ArrayList<String>();
}