I have the following class structure:
Class Human, with message("Hello, ")
Class Townsmen extends Human, with message("I live in town.")
Class Merchant extends Townsmen, with message("I'm merchant.")
Is it possible for an instance of Merchant to say “Hello, I’m merchant.”, using super calls? I have a program in Java, and the code is much more complex, but the idea is the same. In addition I cannot modify Human nor Townsmen classes.
This isn’t possible in Java, which doesn’t allow multiple inheritance. The correct way to do this would be:
With TownMember having whatever logic that townsmen has that merchant inherits.
Since you can’t do that, you’re going to need to have Merchant extend Human and just re-implement that logic.