Can you re-make a method abstract in the inheritance tree?

后端 未结 4 593
春和景丽
春和景丽 2021-01-25 03:09

EDIT:

To be clear: The fact that the design is quite ugly is not the point. The point is, that the design is there and I am in the situation to have to add another sub-c

4条回答
  •  爱一瞬间的悲伤
    2021-01-25 03:29

    You want children of MotorizedVehicle to have a default implementation of bar, but not so for the children of the FlyingMotorizedVehicle.

    abstract class BasicMotorizedVehicle
        // no bar
        ... // Rest of old MotorizedVehicle
    
    class MotorizedVehicle extends BasicMotorizedVehicle
        Foo bar(...) { ... }
    
    class FlyingMotorizedVehicle extends BasicMotorizedVehicle
    

提交回复
热议问题