标签:方法 method src bst nbsp code public imp .net
3.Factory Method(工厂方法)
作用:子类决定哪一个类实例化
JDK中体现:Collection.iterator方法
类图:
abstract class SuperClass { public abstract Person getPerson(); } class Sub1Class { public Person getPerson() { return new Student(); } } class Sub2Class { public Person getPerson() { return new Worker(); } } interface Person { } class Student implements Person { } class Worker implements Person { }
标签:方法 method src bst nbsp code public imp .net
原文地址:http://www.cnblogs.com/liandy0906/p/7236952.html