So with static properties out of the way.
Let's come back to inheritance into a concept related to that and no way of adding methods to classes
which you plan to inherit from.
Here's our department class and as you know we're inheriting from it on the I.T. Department and the
accounting department.
Now we do have debt.
Describe method here in our department class and therefore we can call this on any instance based on
I.T. department and accounting department because these classes are based on department and they have
access to all the properties and methods of that department base class now.
As you learned you can override methods.
So for example here in accounting department we could add our own describe method worship in where I
want to do something different where it may be when I say accounting department I.D. and then access
distort I.D. notice would not work here because ideas a private property of department and therefore
we need to turn this into a protected one so that it's available in classes based on this class as well.
But with that it should work.
And if I now call describe on accounting which we can do of course let's maybe call it out.
These two lines and instead call accounting dot describe down there we should see that new output.
And indeed we see accounting department I.D. d.
Now of course we could also override the described method in the I.T. department.
But sometimes you don't just want to offer the option of overriding a method.
Because that always exists you instead want to force the developers working with a certain class or
extending a certain class to implement a certain method or to override a certain method.
When would you do that.
Well whenever you want to ensure that a certain method is a way lable in all classes based on some base
class in this case department.
But when you also know at the same time that the exact implementation will depend on the specific work.
So when you can't provide a general method but you want to enforce that this method exists but the inheriting
classes will need to provide their own implementation because you can't provide a default implementation
in the base class.
So in such a situation you might want to have an empty method in your base class and now force all classes
based on that class to add and override this method and you can do so by adding the abstract keyword
here.
If you add abstract here you see we get an error that does is only available in an abstract class.
So if you have one method or more with abstract in front of the method you have to add abstract here
in front of class as well.
And now we're good regarding that.
But now you see I have an error here describe cannot have an implementation because it is marked as
abstract.
You have to remove the curly braces add a semicolon and instead add the return type does should have
in this case white.
So now you're just defining how this method should look like what its structure is.
But you're not saying anything else besides this.
Now however we get an error in the I.T. department because it does not implement the inherited abstract
member describe which means we don't offer to describe method here and we do have to do that because
we're based on the department class which is abstract and which has such an abstract method which means
this method has to be implemented by any class based on this the part and class.
So now here in I.T. department we have to add a describe method and in there we can now cancel lock
I.T. department and then do whatever we want.
This can be the same implementation as we have it in the accounting department but it can also be a
different one.
So now with that we can save this and add recompile and we get the almost same output as before but
now we have two different implementations of the described method in our different classes based on
department.
Abstract can therefore be very useful if you want to.
And Forest at all classes based on some other class share some common method or property we can all
have abstract properties but at the same time you want to make sure that you don't have to provide concrete
value to concrete implementation in the base class but instead the inheriting class has to do that all
important abstract classes.
So class is marked as abstract with this keyword can't be instantiated themselves.
So you can't instantiate department.
No.
It's basically just a class that's there to be inherited from.
So that these inheriting classes can be instantiated and inheriting classes are forced to provide concrete
implementations for in this case to describe method following the structure you laid out here.
So with the this keyword referring to a department instance or instance somehow based on Department
including inherit the classes that might be in between and that it doesn't return anything.