Inheritance is said to be an is-a relationship. In the example below we can see 4 classes - but actually, the diagram illustrates that there is one superclass and three sub-classes.
Level is the superclass. WaterWorld, RainbowWorld and DragonWorld are sub-classes which have inherited state and behavior from the super class, as well as having their own unique state and behavior.
In plain English we can say that a WaterWorld object is-a Level object, a RainbowWorld object is-a Level object and a DragonWorld object is-a Level object
Inheritance is a feature supported by many programming languages and lies at the heart of Object Oriented Design.
The example above shows the correct notation to illustrate inheritance in a class diagram.
No comments:
Post a Comment