-
Notifications
You must be signed in to change notification settings - Fork 305
/
Question.java
91 lines (70 loc) · 2.36 KB
/
Question.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
82
83
84
85
86
87
88
89
90
91
package reflection;
import java.util.Date;
import java.util.Objects;
public class Question {
private long questionId;
private String writer;
private String title;
private String contents;
private Date createdDate;
private int countOfComment;
public Question(String writer, String title, String contents) {
this(0, writer, title, contents, new Date(), 0);
}
public Question(long questionId, String writer, String title, String contents, Date createdDate,
int countOfComment) {
this.questionId = questionId;
this.writer = writer;
this.title = title;
this.contents = contents;
this.createdDate = createdDate;
this.countOfComment = countOfComment;
}
public long getQuestionId() {
return questionId;
}
public String getWriter() {
return writer;
}
public String getTitle() {
return title;
}
public String getContents() {
return contents;
}
public Date getCreatedDate() {
return createdDate;
}
public long getTimeFromCreateDate() {
return this.createdDate.getTime();
}
public int getCountOfComment() {
return countOfComment;
}
public void update(Question newQuestion) {
this.title = newQuestion.title;
this.contents = newQuestion.contents;
}
@Override
public String toString() {
return "Question{" +
"questionId=" + questionId +
", writer='" + writer + '\'' +
", title='" + title + '\'' +
", contents='" + contents + '\'' +
", createdDate=" + createdDate +
", countOfComment=" + countOfComment +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Question)) return false;
Question question = (Question) o;
return questionId == question.questionId && countOfComment == question.countOfComment && Objects.equals(writer, question.writer) && Objects.equals(title, question.title) && Objects.equals(contents, question.contents) && Objects.equals(createdDate, question.createdDate);
}
@Override
public int hashCode() {
return Objects.hash(questionId, writer, title, contents, createdDate, countOfComment);
}
}