-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.java
More file actions
81 lines (73 loc) · 1.48 KB
/
Character.java
File metadata and controls
81 lines (73 loc) · 1.48 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
72
73
74
75
76
77
78
79
80
81
/* |||||||||||||||||||||||||||||||||||||||||
CHARACTER CLASS
Allows for the creation of family members
of type Character with accessor and
mutator methods to get the Character's
stats
|||||||||||||||||||||||||||||||||||||||*/
public class Character {
//========================
//===Instance Variables===
//========================
protected int HP;
protected String name;
protected int condition;
protected boolean died;
//==================
//===Constructors===
//==================
public Character() {
HP = 100;
condition = 0;
died = false;
}
public Character(String x) {
this();
name = x;
}
//=============
//===Methods===
//=============
public boolean isAlive() {
if (HP > 0)
return true;
else
return false;
}
public boolean isSick() {
if (condition > 0)
return true;
else
return false;
}
public String getName() {
return name;
}
public void setName( String input ) {
name = input;
}
public int getCondition() {
return condition;
}
public void setCondition( int input ) {
condition = input;
}
public int getHP() {
return HP;
}
public void setHP( int input ) {
HP = input;
}
public void addHP( int input ) {
HP += input;
}
public void subHP( int input ) {
HP -= input;
}
public boolean getDied() {
return died;
}
public void setDied( boolean input ) {
died = input;
}
}