Create a class for Waterbender, Earthbender, Firebender, and Airbender as subclasses of the superclass Avatar. The subclasses provide their actual implementation, Firebender must return a String containing the phrase "Fire attack!”, Waterbender = “Water attack!”, Airbender = "Air attack!”, and Earthbender = "Stone attack!". Create a testdriver called TestAvatar to demonstrate the classes. Apply the concept of Inheritance and Polymorphism.
Sample Output:
Fire attack!
Water attack!
Air attack!
Stone attack!
Default attack!
Comments
Leave a comment