我有接口、抽象方法和更多分类并使用这些引用类型如下。
public interface InterfaceA {
boolean mehod1();
boolean method2();
boolean newMethod(); //When added new method
}
public abstract class AbstractA implements InterfaceA{
// other common method
}
public Class C extend AbstractA //have to override three method
public Class D extend AbstractA //have to override three method
public Class E extend AbstractA //have to override three method but only should be override old method
public Class F extend AbstractA //have to override three method but only should be override old method
这些类派生了 AbstractA 类,我只想在接口中使用新方法,但只实现 C 和 D 类,其他应该只使用旧方法。
应该如何设计?
慕侠2389804
萧十郎
白板的微信
相关分类