CJCoding With Joseph

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:

boss attacks

For a plain Character it prints:

hero attacks

Expected Output:

boss attacks
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.