-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonstreBase.java
More file actions
37 lines (37 loc) · 968 Bytes
/
MonstreBase.java
File metadata and controls
37 lines (37 loc) · 968 Bytes
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
public abstract class MonstreBase implements Monstre{
protected int maxhp;
protected int attaque;
protected int curhp;
protected int maxspeed;
protected int curspeed;
protected String name;
protected String classe;
public boolean is_dead(){
return this.curhp<=0;
}
public boolean takes_damage(int nb){
this.curhp-=nb;
this.curspeed=this.maxspeed;
return this.is_dead();
}
public int attacks(int opponent_speed) throws MortException{
if (this.is_dead()){
throw new MortException("mort");
}
this.curspeed-=opponent_speed;
return this.attaque;
}
public int speed(){
return this.curspeed;
}
public void revive(){
this.curhp=this.maxhp;
this.curspeed=this.maxspeed;
}
public String appellation(){
return this.classe+" "+this.name;
}
public int hp(){
return this.curhp;
}
}