Repository navigation
Expand file tree
/
Copy pathTweet.java
More file actions
73 lines (59 loc) · 1.43 KB
/
Copy pathTweet.java
File metadata and controls
73 lines (59 loc) · 1.43 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
//
// Implement the tweet class according to the problem_set specifications.
//
class Tweet implements Comparable {
// Define the Attributes
private int tweetId;
private String tweetSentiment;
private String tweetText;
// Define a constructor.
public Tweet(int tweetId, String tweetSentiment, String tweetText) {
this.tweetId = tweetId;
this.tweetSentiment = tweetSentiment;
this.tweetText = tweetText;
}
public Tweet() {
// TODO Auto-generated constructor stub
}
public int getTweetId() {
return tweetId;
}
public void setTweetId(int tweetId) {
this.tweetId = tweetId;
}
public String getTweetSentiment() {
return tweetSentiment;
}
public void setTweetSentiment(String tweetSentiment) {
this.tweetSentiment = tweetSentiment;
}
public String getTweetText() {
return tweetText;
}
public void setTweetText(String tweetText) {
this.tweetText = tweetText;
}
// Override the toString method.
public String toString() {
return String.format("%d (%s): %s", this.tweetId, this.tweetSentiment, this.tweetText);
}
// Override .equals
public boolean equals(Object o) {
Tweet tmp = (Tweet) o;
if (this.tweetId == tmp.tweetId) {
return true;
}
return false;
}
// Override compareTo
@Override
public int compareTo(Object o) {
Tweet tmp = (Tweet) o;
if (this.tweetId < tmp.tweetId) {
return -1;
} else if (this.tweetId > tmp.tweetId) {
return 1;
}
return 0;
}
} // End of Tweet class