-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathParticipant.java
More file actions
38 lines (30 loc) · 866 Bytes
/
Participant.java
File metadata and controls
38 lines (30 loc) · 866 Bytes
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
package domain;
import java.util.Objects;
public class Participant {
private final Person person;
private int position;
public Participant(Person person, int position) {
this.person = person;
this.position = position;
}
public void move(Direction direction) {
position = position + direction.offset;
}
public String getParticipantName() {
return person.name();
}
public int getPosition() {
return position;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Participant that = (Participant) o;
return Objects.equals(person.name(), that.person.name());
}
@Override
public int hashCode() {
return Objects.hashCode(person.name());
}
}