A subclass that broke the bill run
transcript
The bill run stopped halfway. One account was never paid. And the code was fine.
Pay 300 from every account. Savings pays. The next is a view-only account. Its withdraw throws. The run stops. The current account is never paid. Nothing in the bill run was wrong.
An account promises: withdraw works, up to the balance. The view-only subclass has the same method, but breaks that promise. The compiler is happy. The bill run is not.
Here's the catch. Liskov is about behaviour, not signatures. The failure shows up in the bill run. Code that did nothing wrong.
Stop claiming a promise you can't keep. A view can look. An account adds withdraw. A view-only account is a view, never an account.
A subclass must keep every promise its parent made. Otherwise the code written for the parent breaks. Test it: run the parent's tests against every subclass.
Full breakdown in the lecture.