Submission 5: Polymorphism and Abstract Classes

Objective: Apply polymorphism and abstract classes to generalize behaviors.

Instructions:

  1. Convert Enemy to an Abstract Class:

    • Declare Enemy as abstract.

    • Define abstract methods such as void specialAttack(Player player).

  2. Implement Abstract Methods in Subclasses:

    • Goblin and Dragon:

      • Implement specialAttack(Player player) with behaviors unique to each enemy.

  3. Introduce Polymorphism in Combat:

    • Use ArrayList<Enemy> to store different enemy types.

    • During combat, invoke specialAttack(Player player) without knowing the specific enemy type.

  4. Enhance the Item Class:

    • Make Item an abstract class.

    • Define abstract methods like void use(Player player).

  5. Implement Polymorphic Item Usage:

    • Allow the player to use items without knowing the specific item subclass.

Deliverables:

  • Updated source code files.

  • Screenshot of program running

COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark