-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWord.java
More file actions
50 lines (39 loc) · 1.07 KB
/
Word.java
File metadata and controls
50 lines (39 loc) · 1.07 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
import java.util.ArrayList;
public class Word {
// The lowercase word in String form.
private String word;
// List of Occurrences of the word within the documents.
private ArrayList<Occurrence> occList;
// No args constructor.
public Word() {
word = null;
occList = null;
}
// Overloaded constructor.
public Word(String lowerCase, int lineNum, int wordNum) {
this.word = lowerCase;
this.occList = new ArrayList<Occurrence>();
occList.add(new Occurrence(lineNum, wordNum));
}
// Adds an Occurrence object into the arrayList.
public void addOccurrence(int lineNo, int wordNo) {
// Adds an Occurrence object to occList.
occList.add(new Occurrence(lineNo, wordNo));
}
// Getter for word.
public String getWord() {
return word;
}
// Getter for Occurence list size.
public int getOccurrence() {
return occList.size();
}
// Getter for Occurence list toString.
public String getOccList() {
return occList.toString();
}
// Setter for word.
public void setWord(String word) {
this.word = word;
}
}