In this assignment you will implement inheritance and run-time polymorphism in a class hierarchy. Then, you'll demonstrate your work in a main method.

1. Follow the steps in order: you stand a much better chance of finishing.

2. Create an abstract class called SuperHero. This is your base class. Add the following properties and getter/setter methods

  • Alias, you pick the date type (every super hero has an alias, right? Batman is Bruce Wayne, etc.)
  • Super power, you pick the data type
  • IsAvenging (Boolean, true = they are currently avenging something)
  • What To Avenge, you pick the data type

3. Add a constructor that accepts three arguments: Alias, Superpower, and WhatToAvenge. Default IsAvenging to 'off'.

4. Add an abstract method: public abstract void Avenge();

5. Add a toString method for SuperHero.

6. Add these classes, methods, and properties to the project. Each class should inherit from SuperHero. These are your serived classes.

  • BatMan
    • Max speed of Batmobile, you pick the data type
    • toString method
    • Avenge method that prints what the BatMan object is currently avenging (here's the polymorphism)
  • Hulk
    • Clothes budget, you pick the data type
    • toString method
    • Avenge method that prints what the Hulk object is currently avenging (here's the polymorphism)
  • BlackWidow
    • Speed (feet per second, integer)
    • toString method
    • Avenge method that prints what the BlackWidow object is currently avenging (here's the polymorphism)

7. Add a Main class and a main method that is the entry point of your project.

8. In the main method:

  • Create an ArrayList of SuperHero objects.
  • Declare and instantiate BatMan, Hulk, and BlackWidow objects
  • Add the objects from the previous step to the ArrayList
  • Write an enhanced for loop to step through the ArrayList and invoke the Avenge method on each element.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.