So now that's the basics about inheritance.
We can also override methods or properties of our base class.
So let's say in the accounting I want to add my own ad employee method.
We can do that.
We can add our own method here and get the name here.
Let's say now here I want to have a different logic for adding that extra if check where to check if
name equals Max.
Well then I want a return and not add Max as an employee because Max is totally unsuited for debt.
Otherwise if the name is not Max I want to add the employee.
Now however we also face another issue.
If I tried to add this to employees we see employees is not a known property.
The reason for that is that employees is private and that's important.
Private properties are really only accessible from inside the class in which they're defined not classes
that inherit from that class.
So employees is available instead of department but not in classes based on department.
So accounting department doesn't have direct access to the employees property.
If we want to grant dead access and still make sure that it's not a property that can be changed from
outside we can switch it to protect it protected us like private but unlike private it's now not just
a way lable in this class but also in any class that extends this class.
So now we can access employees from inside our accounting department here I can now add an employee
if it's not Max.
So they are for now if I go down there and on my accounting I want to add an employee often a max this
should not work if I try to add menu.
This should work.
So if we now save dad and we also output print employee information here and then save that we should
see that indeed we have one employee there which is menu because of my own accounting method logic for
ad employee Max was not added.
So the key takeaway here is that you a can override methods of your base class.
You can add your own implementation and then that implementation is used instead of the base classes
implementation.
And B you also have to control access to properties with protected because if you use private you're
really restricted to this class whereas protected still makes it and accessible from outside but makes
it accessible from inside of classes that extend the base class.