How to make changes to a method which u inherit fromsuperclass?I hava a class called abstract attack

How to make changes to a method which u inherit fromsuperclass?I hava a class called abstract attack.I have anotherclass called useForce. This is my abstractAttack class public abstract class AbstractAttack extends SWAffordanceimplements SWActionInterface { This is the method in my abstract class @Override

public void act(SWActor a) {

  SWEntityInterface target = this.getTarget();

  boolean targetIsActor = target instanceofSWActor;

  SWActor targetActor = null;

  int energyForAttack = getEnergyForAttack();//the amountof energy required to attack with a weapon

  

  if (targetIsActor) {

   targetActor = (SWActor) target;

  }

     

  

  if (targetIsActor && (a.getTeam() ==targetActor.getTeam())) { //don’t attack SWActors in the sameteam

   a.say(“t” + a.getShortDescription() + ” says:Silly me! We’re on the same team, ” + target.getShortDescription()+ “. No harm done”);

  }

  else if (a.isHumanControlled() // a human-controlledplayer can attack anyone

   || (targetIsActor && (a.getTeam() !=targetActor.getTeam()))) { // others will only attack actors ondifferent teams

    

   a.say(a.getShortDescription() + ” is attacking “+ target.getShortDescription() + “!”);

   

   SWEntityInterface itemCarried =a.getItemCarried();

   if (itemCarried != null) {//if the actor iscarrying an item

    if(itemCarried.hasCapability(Capability.WEAPON)) {

     target.takeDamage(itemCarried.getHitpoints()+ 1); // blunt weapon won’t do much, but it will still do somedamage

     itemCarried.takeDamage(1); // weapongets blunt

     a.takeDamage(energyForAttack); //actor uses energy to attack

    }

    else {//an attack with a none weapon

     if (targetIsActor) {

      targetActor.say(“t” +targetActor.getShortDescription()

        + ” is amused by “+ a.getShortDescription()

        + “‘s attemptedattack with “

        +itemCarried.getShortDescription());

     }

    }

   }

   else { // attack with bare hands

    target.takeDamage((a.getHitpoints()/20) +1); // a bare-handed attack doesn’t do much damage.

    a.takeDamage(2*energyForAttack); // actoruses energy. It’s twice as tiring as using a weapon

   }

   

   

   

   //After the attack

   //display if the
a isdead after the attack
   if (a.isDead()) {
       
    a.setLongDescription(a.getLongDescription()+ “, that died of exhaustion while attacking someone”);
    
    //remove the attack affordance of the deadactor so it can no longer be attacked
    a.removeAffordance(this);
   }    //display if the a is not a droid and has negative hitpoints
   else if (target.getClass() != Droid.class&& target.getHitpoints()
    target.setLongDescription(target.getLongDescription()+ “, that was killed in a fight”);
       
    //remove the attack affordance of the deadactor so it can no longer be attacked
    targetActor.removeAffordance(this);
   }    //display if the a is a droid and its hitpoint is below the damage threshold
   else if (target.getClass() == Droid.class&& target.getHitpoints()
    targetActor.removeAffordance(this);
    target.setLongDescription(target.getLongDescription()+ “, that was destroyed”);
   }    //display if the a is a droid and hitpoints is inbetween threshold and 0
   else if (target.getClass() == Droid.class&& target.getHitpoints()
    target.setLongDescription(target.getLongDescription()+ “, that was disabled”);
   }
  } // not game player and different teams
  
} This is the same method in my useForce class.As u can see, thereare a lot of similarities but just the parts highlighted in boldare different.How am I gonna implement the changes withoutrepeating the code that is similar? @Override
public void act(SWActor a) {
  SWEntityInterface target = this.getTarget();
  boolean targetIsActor = target instanceofSWActor;
  SWActor targetActor = null;   if (targetIsActor) {
   targetActor = (SWActor) target;
  }
     
  
  if (targetIsActor && (a.getTeam() ==targetActor.getTeam())) { //don’t attack SWActors in the sameteam
   a.say(“t” + a.getShortDescription() + ” says:Silly me! We’re on the same team, ” + target.getShortDescription()+ “. No harm done”);
  }
  else if (a.isHumanControlled() // a human-controlledplayer can attack anyone
   || (targetIsActor && (a.getTeam() !=targetActor.getTeam()))) { // others will only attack actors ondifferent teams
    
   a.say(a.getShortDescription() + ” is attacking “+ target.getShortDescription() + “!”);
   
   SWEntityInterface itemCarried =a.getItemCarried();
   if (itemCarried == null) {
    //if the actor is not carrying anitem
    a.takeDamage(energyForAttack); // actoruses energy to attack with Force(last resort)
   target.takeDamage((a.getForcepoints()/10)+ 1);//If actor has a lot of force points, it is much greater thanbare handed attack
    }
   
   
   
   //After the attack
   
   if (a.isDead()) {//the actor who attacked is deadafter the attack
       
    a.setLongDescription(a.getLongDescription()+ “, that died of exhaustion while attacking someone”);
    
    //remove the use force affordance of thedead actor so it can no longer be attacked
    a.removeAffordance(this);
    
    
    
   }
   if (this.getTarget().getHitpoints()
    target.setLongDescription(target.getLongDescription()+ “, that was killed in a fight”);
    targetActor.removeAffordance(this);
         
   }
  }
  } // not game player and different teams
   . . .

We are the Best!

course-preview

275 words per page

You essay will be 275 words per page. Tell your writer how many words you need, or the pages.


12 pt Times New Roman

Unless otherwise stated, we use 12pt Arial/Times New Roman as the font for your paper.


Double line spacing

Your essay will have double spaced text. View our sample essays.


Any citation style

APA, MLA, Chicago/Turabian, Harvard, our writers are experts at formatting.


We Accept

Secure Payment
Image 3