If I understood your question correctly, you want something like this:
public void takeDamage(int damage){
shield-=damage;
if(shield < 0){
health+=shield; //shield is negative,so subtracts leftover damage from health
if(health <= 0){
lives--;
health=DEFAULT_HEALTH_VALUE; //replace with your own default values
shield=DEFAULT_SHIELD_VALUE;
}
}
}
0
solved How to create a switch for a takeDamage method