我对使用哪种模式来设计以下场景感到困惑,
Interface GearBox {
int upshift();
int downshift();
int reverse();
}
AutoGearBox implements GearBox{...}
ManualGearBox implements GearBox{...}
现在我想将 DualClutchGearBox 添加到层次结构中。以前的所有变速箱都是单离合器。我该怎么做呢?
带装饰器 -->
DualClutchDecorator implements GearBox{
DualClutchDecorator(GearBox box){...}
}
带桥 -->
GearBox{
GearBoxImpl impl;
....
}
AutoGearBox implements GearBox{...}
ManualGearBox implements GearBox{...}
abstract class GearBoxImpl{}
SingleClutchImpl extends GearBoxImpl{...}
DualClutchImpl extends GearBoxImpl{...}
哪个更好,为什么?