-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArcher.java
More file actions
58 lines (47 loc) · 1.86 KB
/
Archer.java
File metadata and controls
58 lines (47 loc) · 1.86 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
public class Archer extends Hero {
private double bonusExp;
pubalic Archer() {
super();
this.bonusExp = 0.5;
}
public Archer(int health, int level, int experience, int maxHealth, int nextLevelExperience, Inventory inventory, double bonusExp) {
super(health, level, experience, maxHealth, nextLevelExperience, inventory);
this.bonusExp = bonusExp;
}
public boolean gainExperience(int amount) {
amount = amount + (int) (amount * bonusExp);
return super.gainExperience(amount);
}
public double getBonusExp() {
return this.bonusExp;
}
@Override
public void display() {
System.out.println(this.toString());
}
@Override
public String getName() {
return "Archer";
}
@Override
public void upgradeStats() {
bonusExp += 0.1;
int newMaxHealth = super.getMaxHealth() + (super.getLevel() * 10);
super.setMaxHealth(newMaxHealth);
super.setHealth(newMaxHealth);
}
@Override
public String toString() {
String description;
description = "Type:\t\tArcher\n";
description = description + "Health:\t\t\t" + super.getHealth() + "\n";
description = description + "Level:\t\t\t" + super.getLevel() + "\n";
description = description + "Experience:\t\t" + super.getExperience() + "\n";
description = description + "Max Health:\t\t" + super.getMaxHealth() + "\n";
description = description + "Potions\t- Small:\t" + super.getInventory().getSmallPotions() + "\n";
description = description + "\t- Medium:\t" + super.getInventory().getMediumPotions() + "\n";
description = description + "\t- Large:\t" + super.getInventory().getLargePotions() + "\n";
description = description + "BonusExp:\t\t" + getBonusExp() + "\n";
return description;
}
}