I am developing a simple project. And I have a conflict with meaning of Liskov Principle in my project.
I simplified my question of my project with this example:
public class Animal {
public void feed() {
// do something here
}
}
public class Dog extends Animal {
// some methods and attributes
@Override
public void feed() {
// never call parent feed() method (super.feed())
}
}
So, my question is, if I don't call parent method and write a completely new codes in override method, Is this violates Liskov Principle?
thanks.
No, it will not violate the Liskov Principle as long as the subclass' implementation satisfies the expectations of the base class.