forked from learning-zone/java-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
34 lines (27 loc) · 763 Bytes
/
Player.java
File metadata and controls
34 lines (27 loc) · 763 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
package SnakeNLadder;
import java.util.Objects;
class Player {
private String playerName;
private int id;
Player(String playerName, int id) {
this.playerName = playerName;
this.id = id;
}
public String getPlayerName() {
return playerName;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Player player = (Player) o;
return id == player.id && Objects.equals(playerName, player.playerName);
}
@Override
public int hashCode() {
return Objects.hash(playerName, id);
}
}