@Override
 public void hit(Starship ship) {
   if ((ship.getHealth() - this.getDamage()) <= 0) {
     ship.setHealth(0);
     return;
   }
   ship.setHealth(ship.getHealth() - this.getDamage());
 }
Esempio n. 2
0
 @Override
 public void hit(Starship ship) {
   int shieldsDamage = ship.getShields() - this.getDamage();
   if (shieldsDamage <= 0) {
     ship.setShields(0);
     if ((ship.getHealth() + shieldsDamage) <= 0) {
       ship.setHealth(0);
       return;
     }
     ship.setHealth(ship.getHealth() + shieldsDamage);
     return;
   }
   ship.setShields(shieldsDamage);
 }