In this post, I will be showing how we can optimise the code given in the previous post using Inheritance.
- Find the duplicate code and move all of them to a new class (Vehicle). Now check if there are common methods with different implementations, then make those methods as abstract and move them to this new class (Vehicle) and make the class an abstract class as below:
- Now make use of the above classes and see the output
No comments:
Post a Comment