Using the Strategy Pattern to avoid downcasting
问题 I was reading on this site about the Liskov substitution principle. It states: As per the LSP, functions that use references to base classes must be able to use objects of the derived class without knowing it. In simple words, derived classes must be substitutable for the base class. According to this page, if you override a method in the base class and it does nothing or throws an exception, you're in violation of the principle. Suppose I had an abstract class called Weapon , and the