-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComponentVisitor.java
81 lines (63 loc) · 1.87 KB
/
ComponentVisitor.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
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
import java.util.*;
/**
*
* @author jmcgr
*/
public class ComponentVisitor implements StatisticsVisitor{
private int userCount;
private int groupCount = 1;
private int messageCount;
private int posMessageCount;
private double posMessagePercentage;
@Override
public void visitUsers(User user) {
this.setUserTotal(this.getUserTotal() + 1);
}
@Override
public void visitGroups(Group group) {
this.setGroupTotal(this.getGroupTotal() + 1);
}
@Override
public void visitMessages(User user) {
this.setMessageTotal(this.getMessageTotal() + 1);
}
@Override
public void selectMessages(ArrayList<String> tweetList) {
for(String str : tweetList){
if(str.contains("good")){
this.setPosMessageTotal(this.getPosMessageTotal() + 1);
}
}
}
public int getUserTotal(){
return this.userCount;
}
public void setUserTotal(int count){
this.userCount = count;
}
public int getGroupTotal(){
return this.groupCount;
}
public void setGroupTotal(int count){
this.groupCount = count;
}
public int getMessageTotal(){
return this.messageCount;
}
public void setMessageTotal(int count){
this.messageCount = count;
}
public int getPosMessageTotal(){
return this.posMessageCount;
}
public void setPosMessageTotal(int count){
this.posMessageCount = count;
}
public void setPosMessPercentage(int totalM, int posM){
double percentage = (double)posM / (double)totalM;
this.posMessagePercentage = percentage;
}
public double getPosMessPercentage(){
return this.posMessagePercentage;
}
}