Base Method Calls Override
hardQuestion 638Character has a virtual method Name returning "hero" and a non-virtual method Attack that returns Name() + " attacks". Create Boss that overrides Name to return "boss". When Attack runs on a Boss, it must call the overridden Name. Do NOT write a Main method.
For a Boss the program prints the output shown in Expected Output.
For a plain Character it prints:
hero attacks
Expected output
boss attacks= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Inheritance
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.