-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChicken.java
More file actions
53 lines (44 loc) · 1.17 KB
/
Chicken.java
File metadata and controls
53 lines (44 loc) · 1.17 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
public class Chicken extends Animal{
public Chicken(String name){
super(name);
sethp(5);
setSpeed(10);
setAttack(1);
setflight(false);
}
public Chicken() {
this("Chicken");
}
/*peck*/
@Override
public String moveOne(Animal other){
int damage = randomRoll(0,5);
damage *= getAttack();
other.applyDamage(damage, this);
return this + " pecked " + other + " and dealt " + damage + " points of damage.";
}
/*shoot egg*/
@Override
public String moveTwo(Animal other){
int damage = randomRoll(0,10) + 3;
damage *= getAttack();
other.applyDamage(damage, this);
if(Math.random() < 0.500){
return this + " shot an egg at " + other + " dealing " + damage + " points of damage.";
}else{
other.applyDamage(2, this);
return this + "'s egg broke on " + other + "'s face, dealing " + damage + " and 2 extra points of damage.";
}
}
/*eat*/
@Override
public String moveThree(Animal opp){
sethp(gethp() + 5);
setflight(true);
return this + " takes flight and restores 5 hp";
}
@Override
public String moveList(){
return "1. peck / 2. egg / 3. eat";
}
}