|
@ -9,5 +9,41 @@ package tanks; |
|
|
|
|
|
|
|
|
public class Living extends RotationalElement |
|
|
public class Living extends RotationalElement |
|
|
{ |
|
|
{ |
|
|
|
|
|
public int health; |
|
|
|
|
|
public boolean isAlive; |
|
|
|
|
|
|
|
|
|
|
|
public Living() |
|
|
|
|
|
{ |
|
|
|
|
|
health=0; |
|
|
|
|
|
isAlive=true; |
|
|
|
|
|
} |
|
|
|
|
|
public void setHealth(int holdH) |
|
|
|
|
|
{ |
|
|
|
|
|
health=holdH; |
|
|
|
|
|
} |
|
|
|
|
|
public void setAlive(boolean holdA) |
|
|
|
|
|
{ |
|
|
|
|
|
isAlive=holdA; |
|
|
|
|
|
} |
|
|
|
|
|
public int getHealth() |
|
|
|
|
|
{ |
|
|
|
|
|
return health; |
|
|
|
|
|
} |
|
|
|
|
|
public boolean getAlive() |
|
|
|
|
|
{ |
|
|
|
|
|
return isAlive; |
|
|
|
|
|
} |
|
|
|
|
|
/* |
|
|
|
|
|
when method is called,takes health away from living object, |
|
|
|
|
|
if health is less than 0, is alive = false |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
public void takeDamage() |
|
|
|
|
|
{ |
|
|
|
|
|
health-=10; |
|
|
|
|
|
if(health<=0) |
|
|
|
|
|
{ |
|
|
|
|
|
isAlive=false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |