| 1 2 3 4 5 6 7 8 9 10 11 | classA { AInterface a; A(){} AMethod()//一个方法 { a = new AInterfaceImp(); } } |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | InterfaceImplFactory { AInterface create(Object condition) { if(condition = condA) { return new AInterfaceImpA(); } else if(condition = condB) { return new AInterfaceImpB(); } else { return new AInterfaceImp(); } } } |
举报
更多回帖