-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
41 lines (33 loc) · 748 Bytes
/
Player.java
File metadata and controls
41 lines (33 loc) · 748 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
39
40
41
public class Player {
final private String userName = "";
private int pos = 1;
private int health = 100;
private char sym = 'X';
public int getHealth() {
return health;
}
public int getPos() {
return pos;
}
public char getSym() {
return sym;
}
public void setSym(char sym){
this.sym = sym;
}
public void drainHealth(){
health -=10;
}
public void changePos(char operator, int num) {
switch (operator) {
case '+':
pos += num;
break;
case '-':
pos -= num;
break;
default:
System.out.println("error");
}
}
}