Dark theme

Inheritance


Write a program that utilises an agent class inheritance structure to represent different nations of people. Make an Agent class that has a random x and y inside it and functions to get x and y. Inherit this class to make two new classes: one representing English people and one representing another nation. Give each a say_hello function which prints "hello" in their appropriate language. In your main program, show you can make an agent from each sub-class, find each agent's location using the inherited functions, and use the agents' specific say_hello functions. Here's the UML:

UML


Hints and one answer