-
Notifications
You must be signed in to change notification settings - Fork 0
/
WordInformation.java
40 lines (33 loc) · 1.08 KB
/
WordInformation.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
public class WordInformation {
public String word;
public LinkedList<WordOccurrence> occList;
public int size;
public WordInformation() {
this.word = "";
this.occList = new LinkedList<> ();
this.size =0;
}
public WordInformation(String word, int Line, int Position) {
this.word = word;
this.occList = new LinkedList<> ();
occList.insert(new WordOccurrence(Line, Position ));
this.size =1;
}
public void Add (int Line, int Position)
{
occList.insert(new WordOccurrence(Line, Position ));
this.size ++;
}
@Override
public String toString() {
String str = "Word{ " + word + ", frequency= " + size + ", length= " + word.length() + ", locations= " ;
occList.findFirst();
while (!occList.last())
{
str += occList.retrieve().toString();
occList.findNext();
}
str += occList.retrieve().toString();
return str;
}
}