CJCoding With Joseph
15free / daySign inCreate account

Base Method Calls Override

Character 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 — print one after the last line.

Hints4 available
Topics:
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.