-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
53 lines (44 loc) · 1.31 KB
/
Copy pathPlayer.java
File metadata and controls
53 lines (44 loc) · 1.31 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
public class Player {
private String name;
private Environment currentLocation;
private int health;
private int highScore;
private static final int MAXHEALTH = 100;
protected static final int MINHEALTH = 0;
public Player(String name,Environment currentLocation){
setName(name);
setCurrentLocation(currentLocation);
resetHealth();
setHighScore(0);
}
public void setName(String name) {
this.name = name;
}
public int getHealth() {
return health;
}
public static boolean outOfHealth(int health){
return (health<=MINHEALTH);
}
public void resetHealth() {
this.health = MAXHEALTH;
}
public void setHighScore(int highscore) {
this.highScore = highscore;
}
public Environment getCurrentLocation() {
return currentLocation;
}
public void setCurrentLocation(Environment currentLocation) {
this.currentLocation = currentLocation;
}
@Override
public String toString() {
return "Player{" +
"name='" + name + '\'' +
", currentLocation=" + currentLocation +
", health=" + health +
", highscore=" + highScore +
'}';
}
}