-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
71 lines (65 loc) · 1.87 KB
/
Player.java
File metadata and controls
71 lines (65 loc) · 1.87 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public abstract class Player {
protected String playerName;
protected String characterName;
protected int level;
protected int xp;
protected int hp;
private static final int baseXp = 0;
private static final int baseLevel = 1;
private static final int baseHp = 100;
Player(String playerName, String characterName){
this.playerName = playerName;
this.characterName = characterName;
this.level = 1;
this.xp = 0;
this.hp = 100;
}
Player(String playerName, String characterName, int level, int xp, int hp){
this.playerName = playerName;
this.characterName = characterName;
this.level = level;
this.xp = xp;
this.hp = hp;
}
public String getPlayerName(){
return playerName;
}
public void setPlayerName(String playerName){
this.playerName = playerName;
}
public String getCharacterName(){
return characterName;
}
public void setCharacterName(String characterName){
this.characterName = characterName;
}
public int getLevel(){
return level;
}
public void setLevel(int level){
this.level = level;
}
public int getXp(){
return xp;
}
public void setXp(int xp){
this.xp = xp;
}
public int getHp(){
return hp;
}
public void setHp(int hp){
this.hp = hp;
}
public abstract void gainXP(int value);
public String toString(){
String s = new StringBuilder()
.append("Player Name: " + getPlayerName() + "\n")
.append("Character Name: " + getCharacterName() + "\n")
.append("Character Level: " + getLevel() + "\n")
.append("Character XP: " + getXp() + "\n")
.append("Character HP: " + getHp() + "\n")
.toString();
return s;
}
}