-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vote.java
57 lines (51 loc) · 1.17 KB
/
Vote.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
package com.company;
public class Vote {
//person who votes
private Person person;
//date of voting
private String date;
/**
* initialize person and date
* @param person person field
* @param date date field
*/
public Vote(Person person, String date){
this.person = person;
this.date = date;
}
/**
* returns voter
* @return person who votes
*/
public Person getPerson() {
return person;
}
/**
* returns date
* @return date of voting
*/
public String getDate() {
return date;
}
/**
* equality of two object
* @param object is a person
* @return true if equal
*/
public boolean equals(Object object){
if (person.equals(object)){
return true;
}
else
return false;
}
@Override
public int hashCode() {
final int prime = 31;
int hash = 7;
hash = prime * hash + (int) date.length();
hash = prime * hash + (date == null ? 0 : date.hashCode());
hash = prime * hash + (person == null ? 0 : person.hashCode());
return hash;
}
}