publicclass SMChargeWay implements IChargeWay { public ChargeResult doCharge(IChargeEvent event) { // not supported IChargeEvent subclass will come to this overload method. System.out.println("no supported charge event."); }
publicclass Test { publicstaticvoid main(String[] args) { IChargeEvent dtEvent = new DownToneEvent(); IChargeWay smWay = new SMChargeWay();
// I expect the following method printing "DownToneEvent charge process." // But actually, it prints "no supported charge event." dtEvent.chargeBy(smWay); } }