-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdventurer.java
82 lines (58 loc) · 1.57 KB
/
Adventurer.java
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
82
import java.util.ArrayList;
import java.util.Random;
public abstract class Adventurer {
private String name;
private int HP, maxHP;
public Adventurer(String name, int hp) {
this.name = name;
this.HP = hp;
this.maxHP = hp;
}
public Adventurer(String name) {
this(name, 10);
}
public Adventurer() {
this("Lester-the-noArg-constructor-string");
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getHP() {
return HP;
}
public void setHP(int HP) {
this.HP = HP;
}
public int getMaxHP() {
return maxHP;
}
public void setMaxHP(int maxHP) {
this.maxHP = maxHP;
}
public void applyDamage(int amount) {
this.HP = Math.max(this.HP - amount, 0);
}
public int restoreSpecial(int n) {
int restored = Math.min(n, getSpecialMax() - getSpecial());
setSpecial(getSpecial() + restored);
return restored;
}
public abstract String getHomeworkSummary();
public abstract void addHomework(HW homework);
public abstract String getSpecialName();
public abstract int getSpecial();
public abstract void setSpecial(int n);
public abstract int getSpecialMax();
public abstract String attack(Adventurer other);
public abstract String support(Adventurer other);
public abstract String support();
public abstract String specialAttack(Adventurer other);
public abstract String assignHomework(ArrayList<Adventurer> party);
@Override
public String toString() {
return name + " (HP: " + HP + "/" + maxHP + ")";
}
}