There are 5 classes that must contain different sets of methods. The four methods are identical for all classes, the rest vary. Identical methods in all five classes are rendered into an abstract class, from which they inherit these methods. Differing methods are written individually in each class.

But among these other methods there is one, which must also be identical for all classes except one.

Actually, how to deal with it: just describe this method equally in only those four classes out of five, where should it be or are there other options? I just don’t want to add it to the general abstract class, from which everything is inherited, and in the same heir class, override this method, throwing NotImplementedException or NotSupportedException. How are such cases implemented in terms of OOP?

    1 answer 1

    public class A { public void M1() {} public void M2() {} public void M3() {} public void M4() {} } public class B : A { public void M5() {} } public class C : A { ... } public class D1 : B { ... } public class D2 : B { ... } public class D3 : B { ... } public class D4 : B { ... } 

    Five finite classes: C , D1 , D2 , D3 , D4 .