-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMammal.java
49 lines (39 loc) · 911 Bytes
/
Mammal.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
public class Mammal implements Attackable {
protected String species;
protected int health;
protected int strength;
public String getSpecies() {
return species;
}
public void sleep() {
this.health += 2;
System.out.println("zzz");
}
public void setSpecies(String species) {
this.species = species;
}
public int getHealth() {
return health;
}
public void setHealth(int health) {
this.health = health;
}
public int getStrength() {
return strength;
}
public void setStrength(int strength) {
this.strength = strength;
}
public Mammal(String species, int health) {
this.species = species;
this.health = health;
}
public void takeDamage(int damageAmount) {
this.health -= damageAmount;
}
public void battle(Attackable target) {
// decrement health
int damageAmount = 5;
target.takeDamage(damageAmount);
}
}