-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPig.java
More file actions
51 lines (43 loc) · 1.03 KB
/
Pig.java
File metadata and controls
51 lines (43 loc) · 1.03 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
public class Pig extends Animal{
int mudLevel;
public Pig(String name){
super(name);
sethp(15);
setSpeed(8);
setAttack(2);
this.mudLevel = 1;
}
public Pig(){
this("Pig");
}
public int getMud(){
return mudLevel;
}
private void setMud(int n){
mudLevel = n;
}
/*roll*/
public String moveOne(Animal other){
int damage = 1;
damage *= getAttack() * getMud();
other.applyDamage(damage, this);
return this + " rolled on " + other + " and dealt " + damage + " points of damage.";
}
/*bite*/
public String moveTwo(Animal other){
int damage = randomRoll(0, mudLevel);
damage *= getAttack();
other.applyDamage(damage, this);
return this + " bit " + other + " dealing " + damage + " points of damage.";
}
/*eat*/
public String moveThree(Animal other){
sethp(gethp()+3);
setMud(3);
return this + " rolls around in mud and gains 3 mud and 3 hp";
}
@Override
public String moveList(){
return "1. roll / 2. bite / 3. eat";
}
}