title: Receiving an object derived from an abstract class as a parameter in method
body: <p>I'm new to Java and I am currently learning about Abstract classes. Currently I am creating a simple RPG. Suppose I have an abstract class called <code>Person</code>, which extends  to two other classes, <code>Warrior</code> and <code>Wizard</code>.</p>
  
  <p>Now suppose that I have another abstract class called <code>Weapon</code> where from there we can create different types of weapons(swords, axes, bows etc..) which share some basic methods,  that can be overwritten by other inherited classes, such as <code>attack()</code> or <code>maintenance()</code>.</p>
  
  <p>When a <code>Person</code>(<code>Wizard</code> or <code>Warrior</code>) will call the <code>attack()</code> method at some point in the game, I need to know who will be the attacker and who the defender (show I can modify their life bar status, durability of their weapons , etc) .</p>
  
  <p>(Which essentially means, receiving two objects in the <code>attack()</code> method as  parameters).</p>
  
  <p>So here is where I am stuck. The combination of attacker-defender could be <code>Wizard-Warrior</code>, <code>Wizard-Wizard, Warrior-Wizard or Warrior-Warrior</code>.  </p>
  
  <p>How should I implement the <code>attack()</code> method in the <code>Weapon</code> class so it can permit me to receive an object as a parameter, without caring if the object is going to be wizard or warrior ? Could this be possible?</p>
  
  <p>doing something like this for example?</p>
  
  <pre><code>void attack(Person attacker, Person defender)
  {
      // add method logic here
  
  }  
  </code></pre>
  
  <p>Thanks in advance.</p>