3.2.1 How to Represent Inheritance in a Class Diagram

Let's say I have a class of type Employee that has several members.

And we want to show that another class inherits this class. The first thing we will do is add a new class node with the type name.

Then we use the 'Inherits from' tool and click and drag an arrow from the descendant class to the inherited class.

Next we will add a constructor to the descendant class that is the same as the inherited class, but with the specific class name.

Next we will add any methods that are specific to that class. In this case, we only want Attendant objects to be able to do (IncreasePrice, StealItem and SitOnBooth)

Next we want to make a method in the Employee class virtual (TakeBreak). This means that the method has functionality and can be used, but has the capability of being overridden. We will cover exactly what that means in later articles. For now, know that making a method virtual looks like:

Now we have the capability to override that method in a descendant class. This means that the method name/parameter/return will all be the same, but the method will provide a different functionality from the inherited class's method. Again, we will cover this more later. For now, know that an override method looks like: